Converting Excel containing hyperlinks to HTML (Cell reference hyperlinks don't work)

Hi,

I am using Aspose cells 8.3.2 jar to convert Excel to HTML.

The attached Excel contains hyperlinks.

Some of the hyperlinks like

ReferANamedRange

Sheet3!A1:C50

dont work.

Can you please figure out the issue.

Code snippet to convert Excel to HTML:

com.aspose.cells.HtmlSaveOptions htmlSaveOptions = new com.aspose.cells.HtmlSaveOptions(com.aspose.cells.SaveFormat.HTML);

File tempAttachmentsDir = OfficeResourceUtility.createTemporaryFolder(“tmp”);

try {

File htmlFile = new File(tempAttachmentsDir.getAbsolutePath(), “index.html”);

htmlSaveOptions.setAttachedFilesDirectory(tempAttachmentsDir.getAbsolutePath());

setSaveOptionProperties(htmlSaveOptions, outputFormatProperties);

workbook.save(htmlFile.getAbsolutePath(), htmlSaveOptions);

createZipFile(tempAttachmentsDir.listFiles(), outputFile);

} finally {

FileUtils.deleteDirectory(tempAttachmentsDir);

}

Jaspreet16:

Hi,

I am using Aspose cells 8.3.2 jar to convert Excel to HTML.

The attached Excel contains hyperlinks.

Some of the hyperlinks like

ReferANamedRange

Sheet3!A1:C50

dont work.

Can you please figure out the issue.

Code snippet to convert Excel to HTML:

com.aspose.cells.HtmlSaveOptions htmlSaveOptions = new com.aspose.cells.HtmlSaveOptions(com.aspose.cells.SaveFormat.HTML);

File tempAttachmentsDir = OfficeResourceUtility.createTemporaryFolder("tmp");

try {

File htmlFile = new File(tempAttachmentsDir.getAbsolutePath(), "index.html");

htmlSaveOptions.setAttachedFilesDirectory(tempAttachmentsDir.getAbsolutePath());

setSaveOptionProperties(htmlSaveOptions, outputFormatProperties);

workbook.save(htmlFile.getAbsolutePath(), htmlSaveOptions);

createZipFile(tempAttachmentsDir.listFiles(), outputFile);

} finally {

FileUtils.deleteDirectory(tempAttachmentsDir);

}

The cell reference hyperlinks don’t work in HTML output.

Hi,


Thanks for the template file and sample code.

After an initial test, I observed the issue as you mentioned. By converting the
template Excel file containing hyperlinks to HTML via Aspose.Cells APIs,
the Cell referenced hyperlinks don’t work. All the hyperlinks are fine
except “ReferANamedRange” and “Sheet3!A1:C50” in the output HTML file.

e.g


Sample code:


Workbook workbook = new Workbook("Hyperlink.xlsx");

workbook.save("f:\\files\\outHyperlink1.html", SaveFormat.HTML);

I have logged a ticket with an id "CELLSJAVA-41206" for your issue. We will 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 for Java.

Please download and try this fix: Aspose.Cells for Java (Latest Version) and let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-41206) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi,


I am using Aspose cells v8.5.2.4
On converting the attached excel document to HTML, the hyperlink ‘Refer a range’ does not work.
For reference, here’s the sample code.
private static void excelDocumentToHTML() throws Exception{
Workbook workbook = new Workbook(“d:\temp\Copy of CellReferHyperlink.xlsx”);
com.aspose.cells.HtmlSaveOptions htmlSaveOptions = new com.aspose.cells.HtmlSaveOptions(com.aspose.cells.SaveFormat.HTML);
File tempAttachmentsDir = new File(“d:\temp\123”);
try {
File htmlFile = new File(tempAttachmentsDir.getAbsolutePath(), “index.html”);
htmlSaveOptions.setAttachedFilesDirectory(tempAttachmentsDir.getAbsolutePath());
workbook.save(htmlFile.getAbsolutePath(), htmlSaveOptions);
File zipFile = File.createTempFile(“Prefix”, “.zip”);
createZipFile(tempAttachmentsDir.listFiles(), zipFile);
System.out.println(zipFile.getAbsolutePath());
} finally {
}
}
private static void createZipFile(File[] inputfiles, File zipFile) throws FileNotFoundException, IOException {
FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
try {
ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream);
try {
for (int i = 0; inputfiles != null && i < inputfiles.length; i++) {
addFileToZip(inputfiles[i], zipOutputStream, null);
}
} finally {
if (zipOutputStream != null) {
try {
zipOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} finally {
fileOutputStream.close();
}
}
private static void addFileToZip(File file, ZipOutputStream zipOutputStream, String folderHeirarchy) throws IOException {
if (file.isFile()) {
byte[] buf = new byte[1024];
FileInputStream in = new FileInputStream(file);
try {
String originalFileName = file.getName();
String targetFileName = null;
if (folderHeirarchy != null && !folderHeirarchy.isEmpty()) {
targetFileName = folderHeirarchy + “/” + originalFileName;
} else {
targetFileName = originalFileName;
}

// Add ZIP entry to output stream.
zipOutputStream.putNextEntry(new ZipEntry(targetFileName));

// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
zipOutputStream.write(buf, 0, len);
}
} finally {
// Complete the entry
zipOutputStream.closeEntry();
in.close();
}
} else {
File[] childFiles = file.listFiles();
for (int j = 0; childFiles != null && j < childFiles.length; j++) {
if (folderHeirarchy != null && !folderHeirarchy.isEmpty()) {
addFileToZip(childFiles[j], zipOutputStream, folderHeirarchy + “/” + file.getName());
} else {
addFileToZip(childFiles[j], zipOutputStream, file.getName());
}
}
}
}

I have verified using MS Excel that hyperlink works on saving this excel doc as Web Page but via Aspose I am unable to achieve this.

Could you please help on this.

Thanks,
Jaspreet

Hi Jaspreet,


Thank you for sharing the samples.

We have evaluated the presented scenario while using the latest version of Aspose.Cells for Java 8.6.0.3, and we are able to replicate the said issue on our side, that is; after converting the spreadsheet to HTML format, the hyperlink referencing the cell area in the same worksheet does not seem to work. We have logged this incident in our bug tracking system under the ticket CELLSJAVA-41499 for further investigation. Our product team will further look into the details of this problem and we will keep you updated on the status of correction.

Hi,


Please try our latest version/fix: Aspose.Cells for Java (Latest Version)

We have fixed your issue “CELLSJAVA-41499” now.

Let us know your feedback.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-41499) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.