Empty cells are not created with individual <td> elements

I am using Aspose 8.1.0


When I try to get the HTML output of certain range in the table, it has been observed that empty cells are not created with individual elements. Instead they are merged to single column with @colspan attribute.

For your reference, I have attached the xlsx file being used and the html output generated by Aspose.

Following is the code snippet for the same:

Workbook workbook = new Workbook(“C:/187208/TestDoc_1.xlsx”);
com.aspose.cells.Worksheet selectedWorksheet = workbook.getWorksheets().get(“table1”);
Range sourceRange = selectedWorksheet.getCells().createRange(“A1:G3”);
Workbook targetWorkbook = new Workbook(FileFormatType.XLSX);
WorksheetCollection targetWsc = targetWorkbook.getWorksheets();
com.aspose.cells.Worksheet targetWs = (com.aspose.cells.Worksheet)targetWsc.get(0);
Range targetRange = targetWs.getCells().createRange(0, 0, sourceRange.getRowCount(), sourceRange.getColumnCount());
PasteOptions options = new PasteOptions();
options.setPasteType(PasteType.ALL);
targetRange.copy(sourceRange, options);
File htmlFile = new File(“C:/187208/AposeGenerated.htm”);
targetWorkbook.save(htmlFile.getAbsolutePath(), SaveFormat.HTML);


You can observer in the output, for the second row there is colspan=6. Whereas it should have 6 elements.

Character formatting
<td colspan=6 style=‘mso-ignore:colspan;’>

Thanks,
Neeraj

Hi,


I have tested your scenario/ case a bit. I have implemented your scenario in MS Excel manually. I re-saved the file to HTML format. When I open the final HTML file into notepad, I see similar representation of data/ formattings in the cells. Could you try to do the steps manually in MS Excel and see if you could see any difference with the output file generated by Aspose.Cells, if you find any issue/ major difference, please provide the output file and steps involved. Also provide some screen shots in comparison to highlight the problematic areas of the HTML file, we will check it soon.

Thank you.

The mentioned issue is with the HTML output but it seems you tried to reproduce it using XML Spreadsheet 2003 option.


Do the following to reproduce the issue:
- Open the attached excel file in MS Excel.
- Select range A1:G3
- Go to File->Save As option
- In the save as Dialog: (Refer to attached Save As dialog also)
– Select “Save as Type” Web Page(*.html)
– Save Republish the selected range
- Save the HTML file
- Create the HTML output using Aspose using the code snippet described.

Now open both the HTML files in text editor and look into their source to observe the behavior as stated in the the post initially.

For your reference I have also attached the HTML generated by the MS Excel.
Hope this would help you to identify the problem.

Thanks,
Neeraj


Hi,


Thanks for further details.

I actually re-saved file (after copying the range of cells into a new Workbook first) to both SpreadsheetML and HTML file formats. As per your sample code, I first select the range and then copy the range into a new Workbook to be pasted, I then re-saved the Workbook file to HTML format. When I open the final HTML file into notepad, I see similar representation of data/ formattings in the cells. Could you try to do the steps as per the code segment in MS Excel manually and see if you could see any difference with the output file generated by Aspose.Cells.

Thank you.

While taking the HTML output from the MS Excel, select that particular range only (A1:G3) which is being used in the code snippet.


You can compare the attached files AposeGenerated.htm.txt and MSExcelGenerated-A1G3.htm.txt.

One is created by the Aspose whereas another is created by MS Excel.

The one generated by Aspose has colspan=6 in the second row:
Character formatting
<td colspan=6 id=‘tc0’ style=‘mso-ignore:colspan;’ null>

whereas MS Excel generated has six td elements for the same row:
<td height=20 class=xl1524630 align=left style=‘height:15.0pt;font-size:11.0pt;
color:black;font-weight:400;text-decoration:none;text-underline-style:none;
text-line-through:none;font-family:Calibri;border-top:.5pt solid #95B3D7;
border-right:none;border-bottom:.5pt solid #95B3D7;border-left:.5pt solid #95B3D7;
background:#DCE6F1;mso-pattern:#DCE6F1 none’>Character formatting
<td class=xl1524630 style=‘font-size:11.0pt;color:black;font-weight:400;
text-decoration:none;text-underline-style:none;text-line-through:none;
font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none;
border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1;
mso-pattern:#DCE6F1 none’>
<td class=xl1524630 style=‘font-size:11.0pt;color:black;font-weight:400;
text-decoration:none;text-underline-style:none;text-line-through:none;
font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none;
border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1;
mso-pattern:#DCE6F1 none’>
<td class=xl1524630 style=‘font-size:11.0pt;color:black;font-weight:400;
text-decoration:none;text-underline-style:none;text-line-through:none;
font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none;
border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1;
mso-pattern:#DCE6F1 none’>
<td class=xl1524630 style=‘font-size:11.0pt;color:black;font-weight:400;
text-decoration:none;text-underline-style:none;text-line-through:none;
font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:.5pt solid #95B3D7;
border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1;
mso-pattern:#DCE6F1 none’>


Thanks,
Neeraj




Hi,


Thanks for providing further details.

We need to investigate the issue on our end. I somehow observed the issue as you mentioned by comparing both HTML files (one is generated by Aspose.Cells and other is generated by Ms Excel(after selecting only the range as you sugested)). I have logged a ticket with an id “CELLSJAVA-40968” for your issue. We will evaluate and look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hi,

Thanks for using Aspose.Cells.

We have evaluated this issue further. For writing empty cells to html file, ms excel does not give the unique output. Sometimes it writes separate td for every empty cell, sometimes it writes one td with colspan too. It is impossible for us to check all situations that ms excel writes separate td for and others that ms excel writes colspan for.

And we don’t think there is any difference for using multiple td elements and using td with colspan to render the generated html or read cells data back from the generated html.

Hi, in context of the above issue, has there been any fix so far.

Because with Aspose.Cells v8.5.2.4 & with the initial attachment I could observer td elements for empty cells.

–Jaspreet

Hi Jaspreet,

Thanks for your posting and using Aspose.Cells.

We are afraid, this issue CELLSJAVA-40968 has been marked as Won’t Fix, so there is no fix for this issue. Sorry for inconvenience and thanks for your understanding.