some bug fixing

Jul 14, 2011 at 3:25 PM


i downloaded the source (closedxml-68415), and made some tests. my intention was to open a xlsm file, and get values from the sheets

i had some errors, i corrected them so, send to you back the source to check it, and implement in the next version, if you feel they're OK.

when i open the file i had an error, and corrected this in XLWorkbook_Load.cs in 272 line (the index in areas was 1:

                    var rowSections = areas[0].Split('!');

then still in opening a file in XLPageSetup.cs i had problem with SetRowsToRepeatAtTop method, so this i changed to:
        public void SetRowsToRepeatAtTop(String range)
            var arrRange = range.Replace("$", "").Split(':');
            Int32 iTest;
            if (Int32.TryParse(arrRange[0], out iTest))
              SetRowsToRepeatAtTop(Int32.Parse(arrRange[0]), Int32.Parse(arrRange[1]));
              SetRowsToRepeatAtTop(arrRange[0], arrRange[1]);

and added a new method
        public void SetRowsToRepeatAtTop(String firstRowToRepeatAtTop, String lastRowToRepeatAtTop)
          SetRowsToRepeatAtTop(ExcelHelper.GetColumnNumberFromLetter(firstRowToRepeatAtTop), ExcelHelper.GetColumnNumberFromLetter(lastRowToRepeatAtTop));

by these modifications i was able to open my file
then i have issue getting a datetime value from a cell. in my excel the datetime is stored as a long value, and this cannot be cast to DateTime. 
i did the following changes (this is only working getting back a simple date - i don't need time value for now, i don't know how this is working...)
this is in XLCell.cs
        public T GetValue<T>()
            if (!StringExtensions.IsNullOrWhiteSpace(FormulaA1))
                return (T)Convert.ChangeType(String.Empty, typeof(T));
            if (Value is TimeSpan)
                if (typeof(T) == typeof(String))
                    return (T)Convert.ChangeType(Value.ToString(), typeof(T));

                return (T)Value;

            if (Value is IXLRichText)
                return (T)RichText;

            if (typeof(T) == typeof(DateTime) && Value.GetType() == typeof(double))
              // excel interprets the date as long value counting from 1900.1.0
              // so we count from 1899.12.30 - then we have the correct date
              object dt = new DateTime(1899, 12, 30).AddDays((double)Value);
              return (T)dt;
            return (T)Convert.ChangeType(Value, typeof(T));

Jul 14, 2011 at 9:25 PM

Thanks for the feedback, could you please upload or send me the file you're trying to open?

Jul 15, 2011 at 7:13 AM

i'm sorry, but i cannot send you this file, since it contains sensitive information from my company/client

Jul 15, 2011 at 2:50 PM

okay, would you remove irrelevant sheets, delete unused data, change text and numbers to random values then?

Jul 25, 2011 at 3:26 AM

Still with us?

Jul 25, 2011 at 1:09 PM

to be honest we're not using ClosedXml in our project. as i said previously i cannot send you our files, it contains too many sensitive information ...

it is up to you if you include my modifications into any release of ClosedXml ...