Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Apr 25, 2014 12:32 pm

I've already tried the given example in titled Export Data from Listview to PDF with C#/VB.NET. I have no idea where did the cellexport1 came from and why this oleDbConnection1.Open(); is still needed if the given data is already present in the listview. how can I get the data directly from the listview including the column header and the table lines into a PDF file format?

dev1ruch1
 
Posts: 1
Joined: Thu Apr 24, 2014 3:53 am

Mon Apr 28, 2014 3:34 am

Hello,
Sorry for late reply as weekend.
Thanks for your feedback. Sorry for inconvenience, we will correct the codes in our site. And for your requirement, please download the Spire.xls7.4 product and refer the following codes.
Code: Select all
DataTable table = new DataTable();
foreach (ListViewItem item in listView1.Items)
           {
                table.Columns.Add(item.ToString());
                foreach (var it in item.SubItems)
                table.Rows.Add(it.ToString());
            }
Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
sheet.InsertDataTable(table, true, 1, 1);
sheet.Range.BorderAround();
sheet.Range.BorderInside();
book.SaveToFile("result.pdf",FileFormat.PDF);

If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu May 01, 2014 9:43 am

Hello,

Have you tried the method? Does it fulfill your needs? Could you please give us some feedback if convenience?

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.PDF

cron