How to work with Index style in Open xml?

Can someone explain how the style index works in OpenXml? I have a business requirement when I need to apply a background color to certain cells in an excel sheet. And some style is already applied to other cells. So I need to decide which style index I need to apply.

+4
source share
1 answer

The OpenXML style can be confusing when you look at it first. The style of an Excel document falls under a markup language SpreadsheetMLthat is different from Word and PowerPoint.

For typical cells in Excel, only StyleIndex style information is required (as you indicated).

Cell cell16 = new Cell(){ CellReference = "HU1", StyleIndex = (UInt32Value)1U, DataType = CellValues.SharedString };

This corresponds to the s attribute in XML:

      <x:c r="HU1" s="1" t="s">
        <x:v>0</x:v>
      </x:c>

StyleIndex - CellFormat "".

( ) :

  • < == cell styleindex

CellFormat , :

  • ( )
  • ( )
  • ( )
  • ( )

:

// this line is important to your question
CellFormat cellFormat5 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)11U, 
//the rest of the CellFormat definition is not so important to your question
FormatId = (UInt32Value)0U, ApplyFill = true, ApplyBorder = true, ApplyAlignment = true };

: . , B3 , B3 StyleIndex 10.

:

1. , (aka Fill) Fills ( ), . , Fill . , , Fill, , 25.

2. CellFormat, CellFormat 10. CellFormat CellFormat. , CellFormat 53.

3. CellFormat 53 Fill index 25 ( 1).

: B3, StyleIndex 53

. Excel. , , .

, 73-79 : Open XML - - Wouter van Vugt. OpenXml.

+4

Source: https://habr.com/ru/post/1680467/


All Articles