Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind datatable to pdfsharp?

I have a data table like this:

// create dataset
DataSet ds = new DataSet("myDataset");

// create datatable
DataTable dt = new DataTable("myDatatable");

// add columns
dt.Columns.Add("column1", typeof(string));
dt.Columns.Add("column2", typeof(string));
dt.Columns.Add("column3", typeof(string));
dt.Columns.Add("column4", typeof(string));

// insert data rows
dt.Rows.Add("row1-col1","row1-col2", "row1-col3", "row1-col4");
dt.Rows.Add("row2-col1","row2-col2", "row2-col3", "row2-col4");

// add datatable to dataset 
ds.Tables.Add(dt);

// bind dataset & datatable to datagridview
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "myDatatable";

I want create pdf reports using pdfsharp. How to bind datatable to pdfsharp?

like image 519
new bie Avatar asked Sep 19 '26 18:09

new bie


1 Answers

You cannot bind DataTables to PDFsharp.

You can use MigraDoc Foundation (comes with PDFsharp) to create a new document, add a table to that document (with the columns you need) and then add the data to that table.

MigraDoc sample with table:
http://www.pdfsharp.net/wiki/Invoice-sample.ashx

like image 200
I liked the old Stack Overflow Avatar answered Sep 21 '26 07:09

I liked the old Stack Overflow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!