This project has moved. For the latest updates, please go here.

"converter failed to save the file xlsx"

Sep 25, 2010 at 2:48 AM

Hi James here,

Not certain if this is known about, I couldn't find anything refering to it in the discussions.

Thought I would try out epplus on a C# app to create a report based on a xlsx template. Worked for a while then just as I was about to deliver (of course) the error reared its ugly head when reading report into 2003.

The error report pointed to 'Repaired Records: Font from /xl/styles.xml part (Styles)'

After a bit of comparing between the original template, the erronous file and a fixed file I found the following xml.

Original --------------------8<----------------------------

<font>
      <b />
      <sz val="8.5" />
      <color indexed="30" />
      <name val="MS Sans Serif" />
      <family val="2" />
    </font>

Erronous --------------------8<----------------------------

    <font>
      <d:b xmlns:d="http://schemas.openxmlformats.org/spreadsheetml/2006/main" />
      <d:sz val="-2.147484E+09" xmlns:d="http://schemas.openxmlformats.org/spreadsheetml/2006/main" />
      <d:color indexed="30" xmlns:d="http://schemas.openxmlformats.org/spreadsheetml/2006/main" />
      <d:name val="MS Sans Serif" xmlns:d="http://schemas.openxmlformats.org/spreadsheetml/2006/main" />
      <d:family val="2" xmlns:d="http://schemas.openxmlformats.org/spreadsheetml/2006/main" />
    </font>

Fixed --------------------8<----------------------------

 <font>
      <b />
      <sz val="1" />
      <color indexed="30" />
      <name val="MS Sans Serif" />
      <family val="2" />
    </font>

--------------------8<----------------------------

Changed any .5 fonts to whole and no more problems.

Ta, keep up the good work,

James

 

ps I would look further into the code to see why but I just got in trouble for working when on holidays :)

Coordinator
Sep 27, 2010 at 6:16 AM

OK, thanx, i'll have a look at it

Oct 10, 2010 at 2:15 AM
Edited Oct 10, 2010 at 2:46 AM

Hi,

Had another look at this one and just incase you have not been able to look at it, here is my patch. Although I am sure you could see the problem from the data above.

I added to XMLHelper.cs

 

        internal float GetXmlNodeFloat(string path)
        {
            float d;
            if (float.TryParse(GetXmlNodeString(path), out d))
            {
                return d;
            }
            else
            {
                return 0;
            }
        }

 

and replaced

       

_size = GetXmlNodeInt(sizePath);

with


      

 _size = GetXmlNodeFloat(sizePath);

 

don't know if that would break anything else?

ta

James

 

Oct 10, 2010 at 2:55 AM

oops, fixed in 67074