Copying a Worksheet Unhides Filtered Rows - Problem 2

problem 2, if I change the named range to table1, which is the new named-range I added, I will get java.lang.IllegalArgumentException: The row index should not be inside the pivottable report

Hi,

I observed the issue as you mentioned by using the following sample code with your newly attached template file from your original thread. I found that if we change the named-range to “table1” in code an exception: “java.lang.IllegalArgumentException: The row index should not be inside the pivottable report” occurred when rendering to HTML file format.
e.g.
Sample code:

//Apply license for Aspose.Cells for Java.
License license = new License();
license.setLicense("Aspose.Cells.lic");
// attached workbook
String path = "FilteredRows.xlsx";
String namedRng = "table1";
Workbook wb = new Workbook(path);
Name name = wb.getWorksheets().getNames().get(namedRng);
Range rng = name.getRange();
Worksheet sheet = rng.getWorksheet();
Cells cells = sheet.getCells();
int sheetIdx = sheet.getIndex();
int firstCol = rng.getFirstColumn();
int firstRow = rng.getFirstRow();
int colCnt = rng.getColumnCount();
int rowCnt = rng.getRowCount();
int maxCol = cells.getMaxDisplayRange().getColumnCount();
int maxRow = cells.getMaxDisplayRange().getRowCount();
// Create a copy of the worksheet - such that only the copy is modified
int newSheetIdx = wb.getWorksheets().addCopy(sheetIdx);
// BUG NOTE:
// The copied worksheet does NOT have the filter applied and therefore
// the filtered (hidden) rows from the original sheet are now visible
// redefine the ranges using the copied worksheet
wb.getWorksheets().setActiveSheetIndex(newSheetIdx);
sheet = wb.getWorksheets().get(newSheetIdx);
cells = sheet.getCells();
rng = cells.createRange(firstRow, firstCol, rowCnt, colCnt);
// Manually hide all the columns not part of the named range
if (firstCol > 0)
{

cells.hideColumns(0, firstCol);

}
if (firstCol + colCnt < maxCol)
{

cells.hideColumns(firstCol + colCnt, maxCol + 1);

}
// Manually hide all the rows not part of the range
if (firstRow > 0)
{

cells.hideRows(0, firstRow);

}
if (firstRow + rowCnt < maxRow)
{

cells.hideRows(firstRow + rowCnt, maxRow);

}
// Now export the copied worksheet
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
options.setEncoding(Encoding.getUTF8());
options.setHtmlCrossStringType(HtmlCrossType.CROSS);
options.setPresentationPreference(true);
options.setExportHiddenWorksheet(false);
//options.setExportActiveWorksheetOnly(true);
options.setExportImagesAsBase64(true);
options.setCreateDirectory(false);
options.setExpImageToTempDir(false);
options.setHiddenColDisplayType(HtmlHiddenColDisplayType.REMOVE);
options.setHiddenRowDisplayType(HtmlHiddenRowDisplayType.REMOVE);
wb.save("f:\\files\\out1.html", options);//Exception

I have logged a ticket with an id “CELLSJAVA-42307” for your issue. We will look into it soon.

Thank you.

Hi,

Please try our latest version/fix: Aspose.Cells for Java (Latest Version)

Your issue (logged earlier as "CELLSJAVA-42307") should be fixed in it.

Let us know your feedback.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-42307) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.