Hi Aspose Team,
I am looking to generate a number of PDFs , where each pdf should contain the each row from the worksheet.
Lets say, I have 10 row in a sheet, I am looking to generate 10 PDF , with each having its own row data in every pdf file generated.
Is it possible to create? I am looking at C#
@kamalr1994,
It is possible to generate a PDF file for each row in a sheet. Please use following codes and let us know your feedback.
Workbook wb = new Workbook(path + "Book1.xlsx");
Worksheet worksheet = wb.Worksheets[0];
foreach(var row in worksheet.Cells.Rows)
{
Workbook wb1 = new Workbook();
Row row1 = row as Row;
wb1.Worksheets[0].Cells.CopyRow(worksheet.Cells,row1.Index,0);
wb1.Save($"{row1.Index}.pdf", SaveFormat.Pdf);
}
Book1.zip (6.4 KB)
Hi Team,
Thanks a lot for the much needed assistance and help.
It is working
@kamalr1994,
Good to know that your issue is sorted out by the suggested lines of code. Feel free to contact us at any time if you need further help or have some other issue or queries, we will be happy to assist you soon.
ahsaniqbalsidiqui, It helped for me as well, thanks for sharing. It would be nice if kindle app will get a full support, cause sometimes there is a need to open an ebook in it. I love online libraries like this one here ( url: Download Сlassic Books Free Pdf, Epub, Mobi | Fb2BookFree ), and I want simply download some ebooks in different digital formats, like PDF, and I don’t want to have any issues with my Kindle as well.
@vincent5MM,
Thank you for writing to us and glad to know that this code snippet helped you. Please feel free to write us back if you have any other query related to Aspose.Cells. We will be happy to assist you at the earliest.
hi all ,
is it possible to convert the same code to normal VBA code ?
thanks in advance for your support
@edkawy79
Do you want to convert codes to macro VBA ,then run it in MS Excel?
Yes , Please … could you please help me on that
Thanks
@edkawy79
You can try the following vba codes in MS Excel:
Sub ConvertToPDF()
Dim ws As Worksheet
Dim pdfPath As String
pdfPath = ThisWorkbook.Path & "\" & ActiveSheet.Name & ".pdf"
Set ws = ActiveSheet
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfPath, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
hi Simon ,
thanks a lot for your efforts & prompt action. kindly note that this code is saving the full sheet to a new pdf file which is nor really what i need.
as mentioned in the original post , i need to generate a PDF file for each row in a sheet . the pdf file shall contain the header of excel table (row 1) and then subsequent row the new exported pdf file could be named as per value in Column A .
here is sample of my data ( i have file contain more than 2000 rows)
Export to single Row.JPG (129.7 KB)
the outcome after using the code should be as mentioned in these photos named ( Result 01, Result 02 & Result 03)
Result 01.JPG (46.0 KB)
Result 02.JPG (42.8 KB)
Result 03.JPG (46.8 KB)
kindly check attached data sample for easy elaboration .
thanks a lot in advance for your efforts
@edkawy79
You can copy header row and one data row to a new worksheet, then export that worksheet to pdf with VBA codes.
I am strange why you need to do it in MS Excel . You can simply use Aspose.Cells to implement it.
thanks a lot for your your reply , unfortunately i don’t have Aspos.
regards
@edkawy79,
We are sorry but these forums are specific to Aspose APIs, so we cannot help you much regarding the tasks which do not involve Aspose APIs. We are happy to assist you with queries, tasks or issues using Aspose.Cells. If you do not use Aspose APIs, you may search/browse relevant forums or resources for your tasks.
hi , i was not aware about this and i am really sorry to bother you with my queries am really sorry to bother you.
thanks and have a good day
@edkawy79
It’s okay. If you have any questions, please feel free to contact us at any time.