Excel convert to pdf with bookmark

Your Java product is so great.
We are going to buy Java Library soon if my testing is ok.
When I use this command for bookmark:
cellInPage = worksheets.get(i).getCells().get(“A1”);
subPbe.setDestination(cellInPage);
It is ok except if the Cell A1 is hihden, the bookmark does not work.
How do know the call is hidden or not?
Or get next cell that is not hidden automatically.

Thanks,
Chang Shin

Hi,


Thanks for considering Aspose.

Well, if a bookmark refers to a hidden cell, it won’t be added to the Bookmarks list. I have tested using the following sample code, I think it works fine. I have also attached the output PDF file here. Moreover, you may use Row.isHidden() and Column.isHidden() methods to get to know if a row or column is hidden or not. I think you may check if a row or column is hidden so you should not refer your bookmark to it.

Sample code:

//Instantiate a new workbook.
Workbook workbook = new Workbook();
//Get the worksheets in the workbook.
WorksheetCollection worksheets = workbook.getWorksheets();
//Add a sheet to the workbook.
worksheets.add(“1”);
//Add 2nd sheet to the workbook.
worksheets.add(“2”);
//Add the third sheet.
worksheets.add(“3”);
//Get cells in different worksheets.
Cell cellInPage1 = worksheets.get(0).getCells().get(“A1”);
Cell cell2InPage1 = worksheets.get(0).getCells().get(“A2”);
Cell cellInPage2 = worksheets.get(1).getCells().get(“A1”);
Cell cellInPage3 = worksheets.get(2).getCells().get(“A1”);

//Add a value to the A1 cell in the first sheet.
cellInPage1.setValue(“a”);
//Add a value to the A2 cell in the first sheet.
cell2InPage1.setValue(“a2”);
//Add a value to the A1 cell in the second sheet.
cellInPage2.setValue(“b”);
//Add a value to the A1 cell in the third sheet.
cellInPage3.setValue(“c”);

//Hiding the first row of the worksheet
worksheets.get(0).getCells().hideRow(0);

System.out.println(worksheets.get(0).getCells().getRows().get(0).isHidden()); //True - OK

//Create the PdfBookmark entry object.
PdfBookmarkEntry pbeRoot = new PdfBookmarkEntry();
//Set its text.
pbeRoot.setText(“root”);
//Set its destination source page.
pbeRoot.setDestination(cellInPage1);
//Set the bookmark collapsed.
pbeRoot.setOpen(false);
//Add a new PdfBookmark entry object.
PdfBookmarkEntry subPbe1 = new PdfBookmarkEntry();
//Set its text.
subPbe1.setText(“1”);
//Set its destination source page.
subPbe1.setDestination(cellInPage2);

//Add another PdfBookmark entry object.
PdfBookmarkEntry subPbe2 = new PdfBookmarkEntry();
//Set its text.
subPbe2.setText(“2”);
//Set its destination source page.
subPbe2.setDestination(cellInPage3);
//Create an array list.
ArrayList subEntryList = new ArrayList();
//Add the entry objects to it.
subEntryList.add(subPbe1);
subEntryList.add(subPbe2);
pbeRoot.setSubEntry(subEntryList);

//Set the pdf bookmarks, you need to specify the root object here.
workbook.getSaveOptions().setPdfBookmark(pbeRoot);

//Save the pdf file.
workbook.save(“f:\files\out_PdfBookmarks_test.pdf”, SaveFormat.PDF);

If you still have any confusion or issue, kindly give us sample code (runnable), we will check your issue soon. Also provide us your output PDF file here.

Thank you.


After I added this code:
It is ok.
What is the code to loop row and cell?

for ( int j = 0; j < worksheet.getCells().getMaxColumn(); j++ ) {
if ( !worksheet.getCells().isColumnHidden(j) ) {
cellInPage = worksheet.getCells().getCell(0, j);
break;
}

}
Thanks,
Chang Shin

Hi,


It looks and Good to know that you have sorted it out now.

Regarding looping through the rows to get the cell, you may follow your similar approach if it helps, e.g

for ( int i = 0; i < worksheet.getCells().getMaxRow(); i++ ) {
if ( !worksheet.getCells().isRowHidden(i) ) {
cellInPage = worksheet.getCells().getCell(i, 0);
break;
}

}

If you still have any confusion or issue, let us know here, we will try to assist you soon.


Thank you.

Thank you so much.
Your product is so great. but document is not enough for developer.
We will buy java full version in two weeks.

Thanks,
Chang Shin


Hi,

Thanks for your posting and considering Aspose.Cells.

We are pleased to know your issue is resolved. If you encounter any other issue, please feel free to post, we will be happy to help you more.

Here is a link to Aspose.Cells for Java programmers’ Guide for your reference.

http://www.aspose.com/docs/display/cellsjava/Programmers+Guide

We want to email message files that has attached files to convert to one pdf file.
I am testing to convert attached email files in email message file to pdf files.
The email content should be converted to pdf file too.
and I am doing to combine the pdf files to one pdf file with bookmark.
The bookmark should be the attached file name.
but your document is not enough to find the sample code.
I am checking this URL.

http://www.aspose.com/demos/java-components/aspose.pdf.kit/java/insert-pages.jsf

Chang Shin



Hi,


Well, I am afraid, I can only help you regarding Aspose.Cells component here in Aspose.Cells forum. I think for your need, you have to use multiple products. For example, when you want to merge or concatenate different PDFs, you may use Aspose.Pdf.Kit for Java product or Aspose.Pdf for Java product. We recommend you to kindly post your query into Aspose.Pdf.Kit and Aspose.Pdf forums where one of our colleague from Aspose.Pdf teams will help you there:
http://www.aspose.com/community/forums/aspose.pdf-product-family/20/showforum.aspx
http://www.aspose.com/community/forums/aspose.pdf.kit-product-family/215/showforum.aspx
Thank you.