Hi Aspose team
Hi Craig,
- Grid Lines seem to overlap the cell borders in a few places (please check attached snapshot). I have used my own sample to replicate this problem and have logged it as CELLSJAVA-41979.
- Grid Lines aren’t rendering in the HTML. I have used your sample spreadsheet and code by commenting the call to fixCellStyle method and rendering the spreadsheet to HTML with HtmlSaveOptions.ExportGridLines. I have noticed that Grid Lines haven’t rendered at all. I have logged this incident as CELLSJAVA-41980 for further investigation.
Hi Barbar.Raza
Hi Craig,
Hi again,
The issues you have found earlier (filed as CELLSJAVA-41980) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi Babar.Raza
Hi Craig,
Hi Babar.Raza
We take a look about the classes and styles in the result.
For the td rendered correctly, its class is “x39”, which can make the color of the grid line exactly right as the origin file.
However, as for td rendered incorrectly, its class is “x40”, which make the wrong result.
So why using “x40” for this td instead “x39”, though these cells might have the same style in the original Excel file?
result.zip (4.9 KB)
class_x40.JPG (74.2 KB)
class_x39.JPG (72.1 KB)
Thanks for considering Aspose APIs.
We have checked your 1.html and 2.html but we could partially understand your issue. To make us understand this issue precisely, please provide us a simplest Excel file which could replicate your issue with some simplest code.
For example, please check the attached Excel file and the following code and its generated HTML (download link given below). Please provide us something similar. You can definitely add more code if it is really necessary. It will help us replicate and fix your issue quickly.
Thanks for your cooperation in this regard and have a good day.
Java
Workbook wb = new Workbook(dirPath + "sampleExcel.xlsx");
wb.save(dirPath + "out.html");
Sample Excel File Output HTML.zip (14.3 KB)
Hi Shakeel
It seem like that the attachment from old forum is gone.
With the code snippet from the top of this topic, we convert a Excel file to HTML file with part of grid lines rendered incorrectly.
20150109_1.xlsx.zip (7.3 KB)
Please see the comparison image in the attachment.
comparison.JPG (125.0 KB)
We took a look at the result HTML files, and then we found there might be something wrong about the classes in the result.
Please see the HTML/CSS class problem mentioned above.
Craig
Thanks for your help in diagnosing this issue.
There are two issues attached with this thread both are closed now. We will create a new ticket for your current issue.
We have found some problems in grid lines. When we converted your Excel file to HTML using Microsoft Excel 2016, both sheets (i.e. Adv, TODO Check) were right. But when we converted them to HTML using Aspose.Cells, we found issues in “TODO Check” sheet.
Please first download and try the most recent version because it is necessary, as we fix issues in most recent version only.
Here are the screenshots. First one is OK but second one is not OK.
First Screenshot - OK
Second Screenshot - KO
This is the sample code we used for testing.
Java
Workbook wb = new Workbook(dirPath + "20150109_1.xlsx");
wb.save(dirPath + "ByCells" + CellsHelper.getVersion() + ".html");
We have also attached the HTML files generated by Microsoft Excel 2016 as well as Aspose.Cells for Java
Html-generated-by-Excel-2016.zip (7.4 KB)
Html-generated-by-Aspose.Cells.zip (8.6 KB)
Regarding your sample code, please provide your code in the form of Java files which we could run at our end. Because the code you provided is now unformatted and jumbled up and in parts as well as, it is not runnable. Please make sure, when you provide us your runnable sample code, you remove all of your business logic and any other non-Aspose.Cells dependencies.
Hi Shakeel
Could you please provide other way to get 17.6.7?
I can’t access Dropbox from my office, due to our IT restriction.
Craig
I have uploaded the 17.6.7 on another file sharing web site. Please download it and let us know if it is OK in China.
Here is download link.
Hi Shakeel
Can you upload to the forum? I can’t access this service either.
We banned most of the online storage service, due to our IT policy in my company.
(Nothing to do with China, and I am not in China)
Please download all these parts. Remove .remove.zip extension and place all of them in some folder and then extract its content using WinRAR tool. Thank you.
Aspose Cells 17.6.7 for Java - In Parts.part1.rar.remove.zip (2 MB)
Aspose Cells 17.6.7 for Java - In Parts.part2.rar.remove.zip (2 MB)
Aspose Cells 17.6.7 for Java - In Parts.part3.rar.remove.zip (2 MB)
Aspose Cells 17.6.7 for Java - In Parts.part4.rar.remove.zip (93.9 KB)
Hi Shakeel
I got HTTP 500 when getting the attachment you provide.
Is this happening at your side?
500.JPG (61.9 KB)
Thank you very much for the help.
I used so many steps to get 17.6.7 from the link you provided above, and then sent it to my PC :’(
Then I need some time to try it, thanks again.
Craig
I tried with 17.6.7 and found that the problem still exists.
This code snippet of my test case should be runnable:
@Test
public void asposeSaveStream() throws Exception {
String fileName = “20150109_1.xlsx”;
Workbook book = new Workbook(“custom/input/xlsx/” + fileName);
String dirName = fileName;
File file = new File(“custom/output/xlsx/” + dirName);
file.mkdirs();fixCellStyle(book);
for (int page = 0; page < book.getWorksheets().getCount(); page++) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
book.getWorksheets().get(page).setVisible(true); for (int i = 0; i < book.getWorksheets().getCount(); i++) { // only one page for test if (i != page) { book.getWorksheets().get(i).setVisible(false); } } HtmlSaveOptions saveOps = new HtmlSaveOptions(); saveOps.setClearData(false); saveOps.setCreateDirectory(false); saveOps.setExportActiveWorksheetOnly(false); saveOps.setExportHiddenWorksheet(false); saveOps.setParseHtmlTagInCell(true); saveOps.setEncoding(Encoding.getUTF8()); saveOps.setHiddenRowDisplayType(HtmlHiddenRowDisplayType.REMOVE); saveOps.setHiddenColDisplayType(HtmlHiddenColDisplayType.REMOVE); saveOps.setExportImagesAsBase64(true); //saveOps.setExportGridLines(true);
saveOps.setStreamProvider(new IStreamProvider() {
@Override public void initStream(StreamProviderOptions arg0) throws Exception { arg0.setStream(new ByteArrayOutputStream()); }
@Override public void closeStream(StreamProviderOptions arg0) throws Exception { System.out.println(arg0.getDefaultPath()); OutputStream stream = arg0.getStream(); if (stream instanceof ByteArrayOutputStream) { ByteArrayOutputStream bb = (ByteArrayOutputStream) stream; IOUtils.write(bb.toByteArray(), new FileOutputStream("custom/output/xlsx/" + arg0.getDefaultPath())); } } }); book.save(baos, saveOps); IOUtils.write(baos.toByteArray(), new FileOutputStream("custom/output/xlsx/" + dirName + "/" + (page + 1) + ".html"));
}
}
protected void fixCellStyle(Workbook book) {
StyleFlag styleFlagGrid = new StyleFlag();
styleFlagGrid.setBorders(true);
for (int i = 0; i < book.getWorksheets().getCount(); i++) {
Worksheet sheet = book.getWorksheets().get(i);
int maxRow = sheet.getCells().getMaxRow();
int maxCol = sheet.getCells().getMaxColumn();
for (int datai = 0; datai <= maxRow; datai++) {
for (int datay = 0; datay <= maxCol; datay++) {
Cell dataCell = sheet.getCells().get(datai, datay); Style dataStyle = dataCell.getStyle();
if (dataStyle.getBorders().getByBorderType(BorderType.LEFT_BORDER).getLineStyle() == 0) { dataStyle.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, Color.fromArgb(204, 204, 204)); } if (dataStyle.getBorders().getByBorderType(BorderType.RIGHT_BORDER).getLineStyle() == 0) { dataStyle.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, Color.fromArgb(204, 204, 204)); } if (dataStyle.getBorders().getByBorderType(BorderType.BOTTOM_BORDER).getLineStyle() == 0) { dataStyle.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, Color.fromArgb(204, 204, 204)); } if (dataStyle.getBorders().getByBorderType(BorderType.TOP_BORDER).getLineStyle() == 0) { dataStyle.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, Color.fromArgb(204, 204, 204)); } dataCell.setStyle(dataStyle, styleFlagGrid); dataCell.getStyle().setNumber(49); } }
}
}