wordpress hit counter
Exploring Table Markup in Open XML SpreadsheetML - OpenXML Developer - Blog - OpenXML Developer

Exploring Table Markup in Open XML SpreadsheetML

Blog

Samples, Demos, and Reference Articles

Exploring Table Markup in Open XML SpreadsheetML

Rate This
  • Comments 2
Tables are a convenient and useful feature of Open XML SpreadsheetML. This post explores table markup, and links to a screen-cast that shows how to create a table programmatically

The table feature has been part of Excel for some time; most users are familiar with tables. When you convert cells to a table in a spreadsheet, instead of seeing ordinary cells, you see a block of cells that have interesting characteristics. You can sort the table by clicking on the down-arrow in the column heading. You can insert rows in the table, and the rows become part of that table automatically. The banded colors make it easy to read.

It is pretty easy to create a table in Open XML SpreadsheetML. If you have some ordinary cells that have the data that you want to use to create the table, you need to do the following:

• In the worksheet, you need to add a x:tableParts element that specifies a relationship to a table part.

<x:tableParts count="1">
  <x:tablePart r:id="rId1" />
</x:tableParts>

• You need to create a table part that has the appropriate elements and attributes to define the table.
• If the table has special formatting, you need to define the formatting in the x:dxfs element in the Styles part.
The following screen-cast walks through the process of discovering the markup necessary to convert some cells to a table, and shows creating a small Open XML SDK example to convert some ordinary cells into a table.

http://www.youtube.com/watch?v=6B_8K9SHTbw

The zip file attached to this blog post contains the finished result of the screen-cast.
Attachment: ConvertCellsToTable.zip
  • hi ,

    am tryed this code its creating table but values are going null .....can u help me i did nit changed anything in ur file just i changed file path(SpreadsheetDocument.Open(@"C:\Prabhu\Test1.xlsx", true) this oly......

  • hi,

    thank u very much its working fine.....

    first i understood wrongly....sorry for that...........

Page 1 of 1 (2 items)