ramesh
ramesh

Reputation: 23

Generation of report in Excel

I have a spreadsheet that has 28 columns. I want to hide some of the column dynamically based on some condition like if there is no data it should be hided. Is there a way so that the spreadsheet will automatically hide. I have tried with this.

xlsTransformer.setColumnsToHide(new short[]{ (short)1, (short)3 } );

by referring this site. but I got stuck. Please give me your suggestion.

Upvotes: 0

Views: 262

Answers (1)

Prasad Khode
Prasad Khode

Reputation: 6739

I don't see any problem with the statement. Following is the code snippet that I have tried. It hides the Columns B, C & D as we are specifying the numbers 1, 2 & 3.

XLSTransformer transformer = new XLSTransformer();
transformer.setColumnsToHide(new short[]{1, 2, 3});

Workbook workBook = transformer.transformXLS(inputStream, map);

I have tried with jXLS 1.0.6 version and following are the maven dependencies

<dependency>
    <groupId>net.sf.jxls</groupId>
    <artifactId>jxls-core</artifactId>
    <version>1.0.6</version>
</dependency>
<dependency>
    <groupId>net.sf.jxls</groupId>
    <artifactId>jxls-reader</artifactId>
    <version>1.0.6</version>
</dependency>

Upvotes: 1

Related Questions