Is there any alternative way to cell style for all cells in a row, instead of setting it Cell by Cell

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there any alternative way to cell style for all cells in a row, instead of setting it Cell by Cell

Venkata Sagar Varma Muppala
Hi,

As part of our project, we have to build an excel report, which will have
thousands of rows and columns. in this many of the cells in each row will
have different cell styling like, text in green color, text in red color,
different background fills etc.. I have tried applying CellStyle to each
cell in a row. using ..getCell().setCellStyle(). but this operation is
consuming lot of time when many rows and many columns exists. As a result,
for huge data the excel report itself is not getting downloaded forever.

Could some one please suggest a better way to handle this scenario?

Thanks,
Sagar.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Is there any alternative way to cell style for all cells in a row, instead of setting it Cell by Cell

Rob Sargent
Define your styles up front, apply the correct style when you make the cell.

On 1/24/19 4:47 AM, Venkata Sagar Varma Muppala wrote:

> Hi,
>
> As part of our project, we have to build an excel report, which will have
> thousands of rows and columns. in this many of the cells in each row will
> have different cell styling like, text in green color, text in red color,
> different background fills etc.. I have tried applying CellStyle to each
> cell in a row. using ..getCell().setCellStyle(). but this operation is
> consuming lot of time when many rows and many columns exists. As a result,
> for huge data the excel report itself is not getting downloaded forever.
>
> Could some one please suggest a better way to handle this scenario?
>
> Thanks,
> Sagar.
>
>
>
> --
> Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Is there any alternative way to cell style for all cells in a row, instead of setting it Cell by Cell

Greg Woolsey
I often use a "template" document instead of creating a workbook from
scratch.  This isn't an Excel template (XLST), just a plain XLSX file with
no data, only boilerplate like labels.

In that file I can define workbook default styles in Excel, table themes,
and, possibly most important for you, conditional formatting rules.

in your case, I'd suggest defining conditional formatting in such a blank
workbook that formats cells in the ranges you want.

Those can be defined through POI in a blank workbook, but it is tricky to
get right, and much easier to do first in Excel than start with that empty
file.

Open a copy of that file with POI, fill in your data, and save.  When the
resulting file is opened in Excel it should look how you want without
having to specify the style all the way through.

Also, when generating workbooks with POI for download, I most often make
the browser side of things do it in two steps, to avoid request timeouts
and users getting antsy and clicking on stuff they shouldn't while
processing.


On Fri, Jan 25, 2019 at 1:32 PM Rob Sargent <[hidden email]> wrote:

> Define your styles up front, apply the correct style when you make the
> cell.
>
> On 1/24/19 4:47 AM, Venkata Sagar Varma Muppala wrote:
> > Hi,
> >
> > As part of our project, we have to build an excel report, which will have
> > thousands of rows and columns. in this many of the cells in each row will
> > have different cell styling like, text in green color, text in red color,
> > different background fills etc.. I have tried applying CellStyle to each
> > cell in a row. using ..getCell().setCellStyle(). but this operation is
> > consuming lot of time when many rows and many columns exists. As a
> result,
> > for huge data the excel report itself is not getting downloaded forever.
> >
> > Could some one please suggest a better way to handle this scenario?
> >
> > Thanks,
> > Sagar.
> >
> >
> >
> > --
> > Sent from:
> http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>