We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Provide Ability to Export Range as HTML

Hello,

Currently, the way we convert a range within a worksheet to HTML is to manipulate the worksheet by taking the following actions:

  1. Determining the used range in the worksheet.
  2. Hide all rows and columns that are outside the target range.
  3. Iterate all worksheet Shapes and remove any that are outside the range.
  4. Remove any background image on the sheet.
  5. Save the workbook as HTML with the appropriate HtmlSaveOptions.

The problem is that we need to restore the workbook to its original state after the range is saved as HTML. This includes restoring the Workbook’s underlying FileFormatType to XLSX (which becomes HTML after step 5 above).

It would be really great in terms of performance and usability if Cells (for Java) provides a new API that would allow us to export a given range as HTML - leaving the original Workbook intact and without any modifications.

Please note that Excel currently provides this feature via:

  • The UI: Select any range > File > Save As > Save as type “Web Page (*.html)” > Save Selection
  • Excel VBA/Interop: using the following code:
    ThisWorkbook.PublishObjects.Add(xlSourceRange, "Name.html", "Sheet1", "A1:E10", xlHtmlStatic).Publish(true)

Please consider adding this enhancement.

@oraspose

Thanks for using Aspose APIs.

We have logged your feature request in our database as follows

  • CELLSJAVA-42662 - Provide Ability to Export Range as HTML

Once, we will have some fix or other news for you, we will update you in this topic asap.

Hi Shakeel,

We’re wondering if this request has had any progress. This feature would be extremely helpful.

Thanks.

@oraspose,

I am afraid, the feature is not implemented yet. I have logged your concerns against your issue into our database. Once we have an update or eta on it, we will let you know.

@oraspose,

We will support this feature before November 30, 2018.

Keep in touch.

@oraspose,

This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-42662”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@oraspose,

Please try our latest version/fix: Aspose.Cells for Java v18.11.1 (attached)

Your issue should be fixed in it. There are some tips for you:

  1. Adds HtmlSaveOptions.ExportPrintAreaOnly property.

  2. The Java sample code is as follows:
    e.g
    Sample code:

         Workbook wb = new Workbook(filePath + "a.xlsx");        
         wb.getWorksheets().get(0).getPageSetup().setPrintArea("B6:G18");
         wb.getWorksheets().get(1).getPageSetup().setPrintArea("C8:F18");
    
         HtmlSaveOptions options = new HtmlSaveOptions();
         options.setExportPrintAreaOnly(true);
         wb.save(filePath + "out_java.html", options);
         wb.save(filePath + "out_java.xlsx");
    

Let us know your feedback.

Aspose.Cells for Java_v18.11.1.zip (6.3 MB)
files1.zip (10.1 KB)

Thanks Amjad - this is very useful.

Upon preliminary testing, the new API seems fine. However, we’ve noticed some unexpected results.

For example, using the attached workbook InlineCharts.xlsx, we try to print the named range “Line_Chart_Data” with the following code:

String path = [path] + "InlineCharts.xlsx";
String namedRng = "Line_Chart_Data";

Workbook wb = new Workbook(path);

Name name = wb.getWorksheets().getNames().get(namedRng);
Worksheet sheet = name.getRange().getWorksheet();

wb.getWorksheets().setActiveSheetIndex(sheet.getIndex());
sheet.getPageSetup().setPrintArea(name.getRange().getAddress());

HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
options.setExportPrintAreaOnly(true);
options.setExportActiveWorksheetOnly(true);

String htmlFile = path.replace(path.substring(path.lastIndexOf('.')), 
                                              " - " + namedRng + ".html");
wb.save(htmlFile, options);

In this case, we see data from a different named range being shown in the generated HTML file. In fact, using different named ranges in the sample workbook produce unexpected results.

We’re hopeful you can resolve this issue, as it will prevent us from using the new API.

Thanks again.

@oraspose,

Thanks for the sample code with template file.

After an initial test, we were able to reproduce the issue by using your sample code with your template file. You are right, I noticed different named range data is being shown in the generated HTML file. We will investigate your issue in details and check if we need to re-open your ticket again or log a separate ticket for it. We will try to figure it out soon.
The issue is logged as following:

CELLSNET-46465 - Exporting named range data is not correctly rendered to HTML

We are sorry for any inconvenience caused!

@oraspose,

This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-46465”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@oraspose,

Please try our latest version/fix: Aspose.Cells for .NET v18.11.6 (attached)

Your issue “CELLSNET-46465” should be fixed in it.

Let us know your feedback.
Aspose.Cells18.11.6 For .Net2_AuthenticodeSigned.Zip (4.7 MB)
Aspose.Cells18.11.6 For .Net4.0.Zip (4.7 MB)

Hi Amjad. Thank you for the update. Could you please provide a download with the fix for Cells for Java?

@oraspose,

We will soon provide you the Java version/fix which will fix the issue in Aspose.Cells for Java. Hopefully we can provide you the fix in the next week.

Keep in touch.

@oraspose,

This is to inform you that we have fixed your issue for Java now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@oraspose,

Please try our latest version/fix: Aspose.Cells for Java v18.11.7:

aspose-cells-18.11.7.jar.zip (6.4 MB)

Your issue should be fixed in it.

Let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-42662) have been fixed in Aspose.Cells for Java 18.12. You can also get the latest Aspose.Cells for Java version from Maven repos. with simple configurations. Please see the document for your reference: https://docs.aspose.com/display/cellsjava/Installation

This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi