user3734709
user3734709

Reputation: 11

Open XML 2.5 retrieve cell style information

I'm trying to retrieve the cell contents, text formatting (bold, italic, font-family and font-size) and border formatting (line type, line weight, line color) for a range of cells using C# and Open XML 2.5.

I've found plenty of examples for reading the raw cell contents be it numeric or looking up text strings from the SharedStringTable. What I can't find is an example showing how to retrieve the formatting information for a given cell and I'm unsure where to start.

Would anyone by chance have a complete example of this for a single cell?

Upvotes: 1

Views: 1567

Answers (1)

drock19
drock19

Reputation: 161

If you don't have it already, I would suggest you download Open XML SDK 2.5 Productivity Tool

open the file you want the cell information for and reflect the code. The values you want should be in "/xl/Styles.xml" section of the workbook. If you want each individual cells information, follow the path to the "x:row" nodes where you can get the StyleIndex of the cell which maps to a set style (either auto generated or your own custom one)

Path to the row should be workbook >> worksheet>> sheetdata >> row

Also have a look at Formatting Excel Values

HTH

Upvotes: 2

Related Questions