Errors and changed styles after save.

Nov 9, 2012 at 2:31 PM

 using (ExcelPackage package = new ExcelPackage(templateFile))
 {
       package.Save();
 }

Hi,

I've created from scratch simple xlsx template - selected few cels and set borders on it. After saving with above code I get borders set on all cells to the bottom and also alert about errors detected and repaired by excel.

Any ideas?

 

thanks

Dec 5, 2012 at 5:19 AM

Similar issue: Excel 2010 complained about invalid /xl/styles.xml after package.Save() (without any change).

I unzip the saved XLSX file and checked styles.xml under xl folder, and found some unreasonable XML nodes:

<cellStyleXfs count="2">
  <xf numFmtId="0" fontId="0" fillId="0" borderId="0">
    <alignment vertical="center" />
  </xf>
</cellStyleXfs>
<cellXfs count="3">
  <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="1">
    <alignment vertical="center" />
  </xf>
  <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="1">
    <alignment vertical="center" />
  </xf>
</cellXfs>
<cellStyles count="2">
  <cellStyle name="一般" xfId="1" builtinId="0" />
</cellStyles>

cellStyleXfs count=2, but only one xf inside, cellXfs count=3, but only two xf with identical xfld inside, cellStyles count=2, but only one cellStyle inside.
After changing styles.xml to the original version before EPPlus save, the /xl/styles.xml error message gone.

I don't know why EPPlus get incorrect nodes count, but it seems one the the causes of "unreadable content" error.

Dec 5, 2012 at 6:14 AM
Edited Dec 5, 2012 at 6:14 AM

I traced the source and found the bug. (I guess so)

EPPlus\ExcelStyles.cs Line 562 of UpdateXml() method:

Line 561:            //NamedStyles
Line 562:            count = 1; <== Should be count = 0;

After changing the initial value to 0, the problem disappear in my case.

Mar 13, 2013 at 2:16 PM
darkthread wrote:
I traced the source and found the bug. (I guess so) EPPlus\ExcelStyles.cs Line 562 of UpdateXml() method: Line 561:            //NamedStyles Line 562:            count = 1; <== Should be count = 0; After changing the initial value to 0, the problem disappear in my case.
I also faced with the same problem. After changing initial value everything was ok.

Thanks a lot.
Dec 23, 2014 at 9:47 AM
This is still not fixed in current release (4.0.1.1)

Any plans for this?