This project has moved and is read-only. For the latest updates, please go here.

How to use OfficeOpenXml.Table.TableStyles

Mar 23, 2012 at 1:36 PM

hi all,

im creating excel from scratch without loading data from string, file or datatable. Now i dont know how to apply TableStyle to my worksheet object.

any help pls...


Mar 23, 2012 at 2:02 PM
Edited Mar 23, 2012 at 2:11 PM

I´m pretty sure you cant do this without template. You need to change your cell style "line by line". 

Mar 23, 2012 at 3:13 PM
thanks mrxrsd

Bhavtosh Sharma

On Fri, Mar 23, 2012 at 6:33 PM, [email removed] wrote:
> From: mrxrsd
> I´m pretty sure you cant do this without template. You need to change your
> cell style "line by line".
> Read the full discussion online.
> To add a post to this discussion, reply to this email
> ([email removed])
> To start a new discussion for this project, email
> [email removed]
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe on
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at
Dec 5, 2012 at 1:37 AM
Edited Dec 5, 2012 at 6:26 AM

Using V3.1.2.0 \ Excel 2007 SP3

Firstly worksheet.Cells["A1"].LoadFromDataTable(datatable, true, TableStyles.Medium9)  - To load from a datatable and to apply a TableStyle.x onto it can produce a corrupted xlsx spreadsheet file.  Where I have had this happen to me  I was able to bypass the error by not specifying a TableStyle.x in the .LoadFromDataTable method.  And after to define a range and table.  Then apply a TableStyle.  For example:-

worksheet.Cells["A1"].LoadFromDataTable(datatable, true);

var range = worksheet.Cells["A1:B50"]; 

var table = worksheet.Tables.Add(range, "tablename");

table.TableStyle = TablesStyles.Medium9;