Hi,
I am using Aspose.Cells-8.3.2
While generating the HTML output of a range by copying the selection to new workbook, there appear some extra tds in the output.
Here is the source code to copy range to new worksheet & save as html
Workbook book = createWorkBookUsingPasteOptions(namedRange);
book.save(htmlFile.getAbsolutePath(), SaveFormat.HTML);
…
…
private static Workbook createWorkBookUsingPasteOptions(final Range sourceRange) throws Exception {
Workbook newWorkbook = new Workbook(FileFormatType.XLSX);
WorksheetCollection targetWsc = newWorkbook.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);
return newWorkbook;
}
Attached is the sample excel file & output html
How can we prevent these extra columns in the HTML output ?
Thanks,
Neeraj
Hi Neeraj,
Thank you for contacting Aspose support.
I believe you meant the tags that look like as follow. If I am correct in my understanding then you can remove such tags while setting the
HtmlSaveOptions.ExportBogusRowData property to false, whereas the default value is true. Please note, aforesaid API was exposed with the release of
Aspose.Cells for Java 8.3.2.1 and was included in the major release of Aspose.Cells for Java 8.4.0.
HTML
<tr height=“
0”
style=“
display:none”
>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
<td width=“
64”
style=“
width:48pt”
></td>
</tr>
Hi,
I tried with Aspose.cellls -8.3.2.1.
Using the attached excel file, I referred to the dynamic range A72:H87 on the worksheet ‘charts & tables’.
The html output of this range still contains extra td’s.
…
|
|
|
|
Cascarilla bark oil |
Fragrance |
Produced to customer specification |
| //???
| //?
| //?
Highlighted in red the extra td’s for given row.
How to get rid of these extra td’s that are not even part of mentioned dynamic range.
Hi Neeraj,
Thank you for writing back.
I have evaluated your presented scenario while using the latest version of
Aspose.Cells for Java 8.4.0.5 and the following piece of code. By reviewing the resultant HTML, I am unable to observe the mentioned problem. Please try the code with the latest build and feed us back with your results.
In case you are using different approach to render the specific range to HTML format then please share your complete code for thorough investigation in this regard.
Java
Workbook source =
new Workbook(“D:/Treatt_121214_uploaded.xlsx”);
Workbook destination =
new Workbook();
Range sourceRange = source.getWorksheets().get(“Charts & tables”).getCells().createRange(“A72:H87”);
Range destinationRange = destination.getWorksheets().get(0).getCells().createRange(“A1:H16”);
PasteOptions options =
new PasteOptions();
options.setPasteType(PasteType.COLUMN_WIDTHS);
destinationRange.copy(sourceRange, options);
destinationRange.copy(sourceRange);
HtmlSaveOptions html =
new HtmlSaveOptions();
html.setExportBogusRowData(
false);
destination.save(“D:/output.html”, html);