Kindly find below the code snippet which prints a table in Excel.We are using aspose-cells-2.5.1
Issue is that when i set setTextWrapped(true) for a cell,then any image that has
been inserted in the adjacent cells expands to fit the cell height.
Why is the image getting expanded ? Can u please help us out here.
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.getWorksheets().addSheet().getIndex();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().getSheet(sheetIndex);
//Adding a sample value to "A1" cell
Cell w_cell = worksheet.getCells().getCell("A1");
Style w_cellStyle = w_cell.getStyle();
w_cell.setValue("Khushbu Ruchita Seema Ajay Goshnat Pankaj Tarun");
w_cellStyle.setTextWrapped(true);
w_cell.setStyle(w_cellStyle);
String w_fileName = MetricComponentHelper.getImageFileName("de-icon-green_signal");
String w_filePath = w_req.getSession().getServletContext().getRealPath("/");
w_filePath += SystemProperties.FILE_SEPERATOR + "common"+ SystemProperties.FILE_SEPERATOR + "images" + SystemProperties.FILE_SEPERATOR + w_fileName ;
int w_picIndex = worksheet.getPictures().add(0,1,w_filePath);
Picture w_pic = worksheet.getPictures().get(w_picIndex);
//w_pic.setHeight(16);
//w_pic.setWidth(16);
w_pic.setLockAspectRatio(true);
w_pic.setLocked(true);
//Saving the Excel file
workbook.save("C:\\temp\\book1.xls");
Sample.png (61.9 KB)