Hi,
While copying a Range from one sheet to other, I am facing problems with Row heights. Also, any images/icons with in the copied range are also loosing their size properties.
I am using Aspose.cells for java “aspose-cells-18.4” and trying to copy a range from one sheet to another with PasteOptions All.
The results is some what inconsistent especially with row heights. However, column widths, values formatting all looks fine.
Hidden rows are being set with proper height ‘0’, where in non hidden rows seem to have some issue copying row heights.
Below is the sample code that I used. Also, I am attaching the sample file I have used for further analysis. Kindly validate Image properties after copying the Range.
/** Code piece **/
private static final int START_COL = 0;
private static final int END_COL = 500;
private static final int START_ROW = 0;
private static final int END_ROW = 15;
Workbook wb = new Workbook(new FileInputStream(new File(path + fileName + extension)));
Worksheet workSheet = wb.getWorksheets().get(0);
PasteOptions pasteOptions = new PasteOptions();
pasteOptions.setPasteType(PasteType.ALL);
/pasteOptions.setPasteType(PasteType.COLUMN_WIDTHS);
pasteOptions.setPasteType(PasteType.ROW_HEIGHTS);
pasteOptions.setPasteType(PasteType.COMMENTS);
pasteOptions.setPasteType(PasteType.FORMULAS_AND_NUMBER_FORMATS);
pasteOptions.setPasteType(PasteType.VALIDATION);/
Workbook tempWorkBookForReference = new Workbook();
Worksheet tempWorkSheetForRerence = tempWorkBookForReference.getWorksheets().get(0);
tempWorkSheetForRerence.setName(wb.getWorksheets().get(0).getName());
Range target = tempWorkSheetForRerence.getCells().createRange(START_ROW, START_COL,
END_ROW - START_ROW, END_COL);
Range src = workSheet.getCells().createRange(START_ROW, START_COL,
END_ROW - START_ROW, END_COL);
target.copy(src, pasteOptions);
tempWorkBookForReference.save(path + fileName + “_CopyWithPasteOptions” + extension);
/** Code piece **/
Kindly validate and advice me of what can be done to achieve copying a Range from one sheet to another with Column_Widths, Row_Heights, Values, Formatting, Formula, Validations etc…
Sample.zip (18.4 KB)
Regards,
Kalyan