We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

PdfTableLight cannot set custom rows and columns

Hello,

I'm having an issue creating custom rows and columns using the PdfTableLight APIs.

I'm doing the following and my row headers are showing but no rows are getting added. It works if I don't use TableDirect. Am I doing something wrong?

// Set the DataSourceType as Direct

table.DataSourceType = PdfLightTableDataSourceType.TableDirect;

            // Creating Columns

            table.Columns.Add(new PdfColumn("Roll Number") { Width = 80 });

            table.Columns.Add(new PdfColumn("Name"));

            table.Columns.Add(new PdfColumn("Class"));

            // Adding Rows


            table.Rows.Add(new object[] { "111", "test", "test" });



4 Replies

PH Praveenkumar H Syncfusion Team September 16, 2015 01:21 PM UTC

Hi Wes,

Thank you for using syncfusion products,

We are currently looking into this odd behavior, however we are suggesting you to use without “table.DataSourceType = PdfLightTableDataSourceType.TableDirect;”. We will update you the further full details on 18 September 2015.
 
With Regards,
Praveen


PH Praveenkumar H Syncfusion Team September 18, 2015 07:18 AM UTC

Hi Wes,

Thank you for your patience,

We are suggesting you to use the following code to create a direct table

PdfLightTable table = new PdfLightTable();

// Set the DataSourceType as Direct

table.DataSourceType = PdfLightTableDataSourceType.TableDirect;

table.Style.DefaultStyle.BorderPen = new Syncfusion.Pdf.Graphics.PdfPen(Syncfusion.Drawing.Color.Red);

// Creating Columns


table.Columns.Add(new PdfColumn("Roll Number") { Width = 80 });


table.Columns.Add(new PdfColumn("Name"));


table.Columns.Add(new PdfColumn("Class"));


// Adding Rows

table.Rows.Add(new string[] { "111", "test", "test" });


// Adding Rows

table.Rows.Add(new string[] { "111", "test", "test" });


// Adding Rows

table.Rows.Add(new string[] { "111", "test", "test" });


// Adding Rows

table.Rows.Add(new string[] { "111", "test", "test" });


table.Draw(page,new RectangleF(0,0,500,500));


The sample project is attached for your reference.

http://www.syncfusion.com/downloads/support/forum/120264/ze/PdfTableCreation1240925891.zip


Please try this and let us know the result.


With Regards,

Praveen



WE Wes September 22, 2015 11:49 AM UTC

Praveen, thanks for the response. Using strongly typed strings does in fact cause the rows to be created. This should unblock me for now, thanks!


CM Chinnu Muniyappan Syncfusion Team September 23, 2015 04:55 AM UTC

Hi Wes,


Thank you for your update. We are glad to know that our solution helped.

Please let us know if you have any other queries.


Regards,

Chinnu


Loader.
Live Chat Icon For mobile
Up arrow icon