This is based on customer request,
Here is a sample script,
// create a report var report = aqua.report.newReport(); // create a dataset var dataset = aqua.data.newDataSet(["ShipCountry", "Freight"]); var columnStructure = dataset.getColumnStructure(); columnDescriptor = columnStructure.getColumn(1); columnDescriptor.setSqlType(java.sql.Types.DECIMAL); columnDescriptor.setJavaType("java.math.Double"); dataset.addRowWithValues("US", 0.10); dataset.addRowWithValues("UK", 2.50); dataset.addRowWithValues("Japan", 3.00); dataset.addRowWithValues("Canada", 2.0); dataset.addRowWithValues("France", 2.00); dataset.addRowWithValues("Germany", 1.50); // create a dataset settings var settings = aqua.report.newReportDataSetSettings(); settings.setColumnHeader(1,"Freight\nDetails"); settings.setColumnNumericFormat(1, "##0.00%"); //settings.setHtmlDataCellStyle(0 ,1,"color:red;height: 40px;"); settings.setTitle("Report with custom settings"); settings.addCustomRowDivider(1,"<br><br> "); // add dataset to report with custom settings report.addDataSet(dataset, settings); // present report as a plain text grid aqua.console.println(report.renderText()); aqua.response.write(report.renderHtml()); var excel = aqua.data.excelSpreadsheet("/tmp/a.xls"); excel.setAutoResize(true); report.saveTo(excel); excel.save();
Hi Sachin,
I reviewed ADS implementation and Aspose APIs, let's discuss this enhancement whenever you are available.
> Column formatting does not get applied in excel sheet
In the current Open API implementation, column formatting for Date/Time/Number is hard-coded when saving a report to an Excel file. Aspose provides APIs for setting display formats of numbers and dates at cell/column/row level. However, the format specified by user, via Open API, is a Java format which certainly will not work for Aspose/Excel. We need to decide whether we want to convert Java format to Excel format implicitly, or do something else, for implementing this improvement. Format conversion can be complicated and locale specific; in addition, an Excel format might not be valid in Java. BTW, ExcelUtils.convertJavaDateFormatToExcel(String javaDateFormat) is available but not for Number.
> setAutoResize does not support multi line
Open API/Report currently does not support this. This has something to do with wrapping text in a cell.
Try this in an Excel file:
(1) Open an Excel file.
(2) Click an empty cell and type 'one', followed by 'ALT+Enter', followed by 'two', then press 'Enter'.
(3) Now the cell has two lines displayed in it.
(4) Right-click the cell you just edited and choose 'Format Cells...'.
(5) In 'Format Cells' window, click 'Alignment' tab; the 'Wrap text' field should be checked.
(6) Uncheck 'Wrap text' and click 'OK' button.
(7) Now, the cell content is displayed in one line.
(8) If you bring up 'Format Cells' window and check the 'Wrap text' again, the newline in the cell will be respected.
If we want to support multi-line for auto-resize, then we likely need to turn on 'Wrap text' for all cells.
Issue #9097 |
Closed |
Completion |
No due date |
No fixed build |
No time estimate |
1 issue link |
relates to #9657
Issue #9657Allow setting formatting preferences like font size and alternating row color - "View as Spreadsheet" |
Hi Sachin,
I reviewed ADS implementation and Aspose APIs, let's discuss this enhancement whenever you are available.
> Column formatting does not get applied in excel sheet
In the current Open API implementation, column formatting for Date/Time/Number is hard-coded when saving a report to an Excel file. Aspose provides APIs for setting display formats of numbers and dates at cell/column/row level. However, the format specified by user, via Open API, is a Java format which certainly will not work for Aspose/Excel. We need to decide whether we want to convert Java format to Excel format implicitly, or do something else, for implementing this improvement. Format conversion can be complicated and locale specific; in addition, an Excel format might not be valid in Java. BTW, ExcelUtils.convertJavaDateFormatToExcel(String javaDateFormat) is available but not for Number.
> setAutoResize does not support multi line
Open API/Report currently does not support this. This has something to do with wrapping text in a cell.
Try this in an Excel file:
(1) Open an Excel file.
(2) Click an empty cell and type 'one', followed by 'ALT+Enter', followed by 'two', then press 'Enter'.
(3) Now the cell has two lines displayed in it.
(4) Right-click the cell you just edited and choose 'Format Cells...'.
(5) In 'Format Cells' window, click 'Alignment' tab; the 'Wrap text' field should be checked.
(6) Uncheck 'Wrap text' and click 'OK' button.
(7) Now, the cell content is displayed in one line.
(8) If you bring up 'Format Cells' window and check the 'Wrap text' again, the newline in the cell will be respected.
If we want to support multi-line for auto-resize, then we likely need to turn on 'Wrap text' for all cells.