Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying styles to Excel cells #3

Open
sstativa opened this issue Mar 19, 2018 · 0 comments
Open

Applying styles to Excel cells #3

sstativa opened this issue Mar 19, 2018 · 0 comments

Comments

@sstativa
Copy link

sstativa commented Mar 19, 2018

Hi, is there any detail description of how to deal with styles in Excel documents?

So far, this is what I found

  • If I create a new cell style it will be in styles.xml in cellStyles section
  • Knowing the name of my style I have to find xfId
    <cellStyles count="4">
        <cellStyle name="b" xfId="1" xr:uid="{A7F9842F-456D-3F46-9279-08C7AB310620}"/>
        <cellStyle name="g" xfId="2" xr:uid="{AEB4E562-675A-AE4F-A58D-992F5F115901}"/>
        <cellStyle name="n" xfId="3" xr:uid="{9D709C8C-79FD-E446-BF82-0F2831F359C2}"/>
        <cellStyle name="Normal" xfId="0" builtinId="0"/>
    </cellStyles>
  • Knowing the value of xfid I have to find a correspondent xf tag in cellXfs section
    <cellXfs count="44">

        ...  

        <xf numFmtId="0" fontId="15" fillId="9" borderId="1" xfId="1">
            <alignment horizontal="center"/>
        </xf>
        <xf numFmtId="0" fontId="14" fillId="8" borderId="1" xfId="2">
            <alignment horizontal="center"/>
        </xf>
        <xf numFmtId="0" fontId="16" fillId="10" borderId="1" xfId="3">
            <alignment horizontal="center"/>
        </xf>

        ...

    </cellXfs>
  • The index or in other words "position" of xf tag inside the cellXfs section will be the style number that I have to assign to the cell to have this cell styled.

Questions,

  • Is there any way to access styles.xml file in OpenTBS to calculate the "position" of my style within cellXfs knowing the name of my created style?
  • I tried to "re-assign" the value of style attribute in generated document, but it did not work for me. The final document had "internal" index for the style instead of a new index that I wanted to assign.
    For example, my cellXfs has 44 styles (in other words - xf tags), for some cells I want to assign an alternative style by having this construction in cells [row.cell.st;att=c#s] where row.cell is some value from MergeBlock. By having this [row.cell.st][row.cell.st;att=c#s] I can confirm that the value of row.cell.st is correct, but this does not affect the attribure within worksheets/_ref/sheet1.xml
    <c r="E4" s="41">
        <v>2</v>
    </c>

Where 41 is an internal style that I was trying to "override". Am I doing something wrong? How to assign a new value to s attribute? [row.cell.st;att=c#s] did not work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant