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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Table column format

Thread ID:

Created:

Updated:

Platform:

Replies:

101249 Oct 11,2011 03:30 AM UTC Mar 2,2018 05:55 AM UTC ASP.NET Web Forms (Classic) 7
loading
Tags: PDF
Chloe Vuillet
Asked On October 11, 2011 03:30 AM UTC

Hi,

I am creating a pdf containing several tables that are drawn using datas contained in dataTables.
For each dataTable, I have a list of column indexes (for eg 1,3 and 6) corresponding to columns I would like to highlight using a different format(for eg a different brush color) as they are breakdowns of the column they come after, how can I do that?
Or is there a way to change the styles of the columns that have a certain code in there header?

Thanks ,
Clo


Geetha M [Syncfusion]
Replied On October 11, 2011 11:42 AM UTC

Hi Clo,

Thank you for your interest in Syncfusion products.

Yes, it is possible to apply formatting to cell / row /column level. If you are using PdfLightTable, you can make use of BeginCellLayout event or PdfCellStyle. Please check the following documentation for more details:

BeginCellLayout event

Cell Style

If you are working with PdfGrid, you can apply format in the PdfGridCell. Here is the documentation link:
Cell Content Formating

Please try this and let me know if you have any questions.

Regards,
Geetha


Chloe Vuillet
Replied On October 13, 2011 09:44 AM UTC

I am having trouble implementing this.
If we use the class attached:
I have a "TableTest" struct that contains
- a dataTable
- a list of int
I created an element toto with a DataTable that contains 3 columns and just added 2 to the list of int => I created three cell styles :
- the default
- the alternate
- the "breakdownStyle" => one I want to use for the columns whose indexes belong to the list of int (eg 2 here).

How can I do that? I tried using the BeginCellLayout event but couldnt manage it.

Thanks and regards
Clo



Test_6879ec52.zip

Geetha M [Syncfusion]
Replied On October 17, 2011 10:27 AM UTC

Hi Clo,

Thank you for the details.

You can make use of the following code snippet to achieve the expected behavior:

table.BeginCellLayout += new BeginCellLayoutEventHandler(table_BeginCellLayout);

void table_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)
{
if (args.CellIndex == 1)
{
string text = args.Value;
args.Graphics.DrawString(text, breakdownStyle.Font, breakdownStyle.BackgroundBrush, args.Bounds);
args.Graphics.DrawRectangle(breakdownStyle.BorderPen, args.Bounds);
args.Skip = true;
}
}

Please try this and let me know if you have any questions.

Regards,
Geetha


Raghav Gokakkar
Replied On November 10, 2011 12:49 PM UTC

Hi,

I need to have different color and format for each cell depending on the value. When I tried above snippet (args.Skip = true), all lines of the table get written at the same location (overlap each other). Without Skip=true, it works but the text gets written twice in each cell. Can you please advice.


Geetha M [Syncfusion]
Replied On November 11, 2011 09:52 AM UTC

Hi Raghav,

Thank you for your interest in Syncfusion products.

In order to achieve the desired behavior, could you please make use of PdfGrid instead of PdfLightTable. Instead of making use of events, you can format the cell before drawing PdfGrid. Please check our documentation in the following link for more details.

Cell Content Formatting

Please try this and let me know if you have any questions.

Regards,
Geetha


Dylan
Replied On March 1, 2018 12:47 AM UTC

Hi Raghav,

Thank you for your interest in Syncfusion products.

In order to achieve the desired behavior, could you please make use of PdfGrid instead of PdfLightTable. Instead of making use of events, you can format the cell before drawing PdfGrid. Please check our documentation in the following link for more details.

Cell Content Formatting

Please try this and let me know if you have any questions.

Regards,
Geetha


n/a

Sowmiya Loganathan [Syncfusion]
Replied On March 2, 2018 05:55 AM UTC

Hi Chleo, 

Apply different color and format for each cell depending upon the value can be achieved by using PdfGridCellStyle and PdfStringFormat class. Please refer the below UG documentation link for more details :  

Customize the cell in PdfGrid 

Customize the columns in PdfGrid 

Please try this in your end and let us know if you need any further assistance on this. 

Regards, 
Sowmiya L 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;