i'm new to your products and trying to figure out which of your products will do the thing i need to do. am i able to only use Aspose.Pdf to convert an excel file to pdf? or do i need to purchase only Aspose.Cells instead to do the conversion from excel to pdf?
i've been looking at aspose.pdf product info and it keeps saying it can convert word and excel files to pdf but i don't see your example code demos showing how to do that.
bottom line, i need to be able to convert excel files to pdf. and i need to be able to convert individual worksheets inside the excel file/workbook to pdf.
i see. the reason i ask about Aspose.Pdf because it can convert many other things which we like and may find using later down the road like converting images to pdf and xml to pdf.
if Aspose.Pdf can directly convert excel to pdf, then we wouldn't need to think any further and just buy Apose.Pdf.
but i guess from what i'm sensing, Aspose.Pdf cannot directly convert excel files to pdf. Would that be a correct assumption?
Can Aspose.Cells go inside an excel file/workbook and extrapolate out individual worksheets and convert each worksheet into a pdf file?
ultimately, i need to be able to convert each worksheet in a workbook into its own pdf file. so if a workbook has 5 unique worksheest, i need to be able to convert them where the result outcome would be 5 invidually unique pdf (1 pdf for each worksheet in the workbook).
Yes, Aspose.Pdf cannot directly convert Excel files to Pdf. Also, Aspose.Cells can go inside an excel file/workbook and extrapolate out
individual worksheets and convert each worksheet into a pdf file.
Please see a code example how to save each of your worksheet as separate pdf.
C#
string filePath = @“C:\Downloads\test.xlsx”;
Workbook workbook = new Workbook(filePath);
int sheetCount = workbook.Worksheets.Count;
//Make all sheets invisible except first
for (int i = 1; i < workbook.Worksheets.Count; i++)
{
workbook.Worksheets[i].IsVisible = false;
}//for
//Take pdfs of each sheet
for (int j = 0; j < workbook.Worksheets.Count; j++)
//Make all sheets invisible except first for (int i = 1; i < workbook.Worksheets.Count; i++) { workbook.Worksheets[i].IsVisible = false; }
why do u need to make each worksheet invisible?
workbook.Save("F:\\downloads\\sheet-" + ws.CodeName + ".pdf"); how does this line of code know what sheet to save? it's just passing a filepath with the name of the new pdf file that is to be created and saved on the drive.
Aspose.Cells convert your xls/xlsx file into PDF as Ms-Excel renders it in a Print Preview. It converts your entire workbook’s visible sheets.
Since you need separate pdf for your each of sheet, we need to make all other sheets invisible/hidden. Once you get the pdf of first worksheet, you will make second unhidden and all others hidden and then save it in pdf format and this will goes on till the last worksheet.
The code name in the last line is just used to save the pdf in new file rather than overwriting any existing file.
so does the print preview screen actually show up? because i just need it to convert and save behind the scenes without any prompt or screen showing up.
I have a couple of scenarios i need research on for what we need to do:
Scenario 1:
Lets say I have a workbook of 5 worksheets. Am I able to:
Extract out worksheet 3 through code
Create a new workbook and insert worksheet 3 into the NEW workbook, through code
Then while the new workbook object is in memory, convert to a pdf file and save it to a folder on my drive???
Scenerio 2:
Lets say I have a workbook of 5 worksheets. Am I able to:
Select certain worksheets and have those converted into 1 pdf file? So lets see i needed worksheet 1, 3, & 5 all converted together into 1 single pdf file that has 3 pages in it, one for each of the selected worksheets, can that be done by setting Worksheets[1], Worksheets[3], and Worksheets[5] 's IsVisible = true so those 3 selected worksheets are visible?
Yes, you can do so, Aspose.Cells will allow you to copy worksheet from one workbook to another, it also allows you to create new workbook from scratch.
So, you can split your single workbook into multiple workbooks and save each of them to pdf separately.
At the moment, i'm trying to convert an excel file to pdf but not save it to a folder on my drive but instead, once converted, the Save() method of the Aspose.Cells.Workbook object needs to return a byte[] object.
is there a way to get an in memory byte[] object of the converted excel file? so basically, convert file to byte[] and the contents in the byte[] is the converted excel file to pdf.
can Aspose.Cells load an html file and convert it to PDF. I'm going through the documentation, and it looks like it can but i need to double check and confirm.