About dates and different formats and general cell types.

29 views
Skip to first unread message

Matti Jorlen

unread,
Feb 5, 2009, 7:35:19 AM2/5/09
to excellibrary
I am trying out excellibrary atm and finding that the date format of
my test excel file is not natively supported by the current codebase.
In my excel file the formatstring of the cells format is "YYYY/MM/DD"
this is not recognized by the Cellformat class. I added the format to
the Cellformat lookup table. Which works as expected. Format is
recognized and cell is has FormatType "Date".

I dont know very much about the format of excel files, what is stored
there and how you read it. It is a poor solution when you have to look
at the format string and try to decide what type (date, percentage or
whatnot) the format string is supposed to describe.
My understanding so far is that this is the way Excellibrary currently
operates.

My application requires me be able to convert data to and from excel
files. Before I added "YYYY/MM/DD" to CellFormat class the data I
recieved was a number representing days from 1901-01-01.
The only clue the Cell could give me that about whether it contained a
date was the formatstring. Since the FormatType property hade failed
recognize the format.

What concerns me is that if a user of my application manages to come
up with a date format unknown to Excellibrary it wont work as
expected.

Is there no way to read formatype without looking at formatstring?

/Matti Jörlén

Jerry

unread,
Feb 6, 2009, 7:37:24 PM2/6/09
to excellibrary
From my understanding, the native excel file only stores 5 kind of
cell type: string, numeric, formula, boolean and error. Excel uses
format string to render the value and present to the user.

The aim of FormatType is to replicate the standard format string and
its type in Excel. As those standard format string are known, they are
easy to convert to the correct .NET types. As for custom format
string, we definitely need extra class to parse the format string and
then guess the correct type.

I guess we can implement something similar to this data formatter
class in POI:
http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFDataFormatter.html

Jerry.

Matti Jorlen

unread,
Feb 25, 2009, 4:58:32 PM2/25/09
to excellibrary
Then I understand what you are up against. I will keep myself
updated.


On 7 Feb, 01:37, Jerry <jet...@gmail.com> wrote:
> From my understanding, the native excel file only stores 5 kind of
> cell type: string, numeric, formula, boolean and error. Excel uses
> format string to render the value and present to the user.
>
> The aim of FormatType is to replicate the standard format string and
> its type in Excel. As those standard format string are known, they are
> easy to convert to the correct .NET types. As for custom format
> string, we definitely need extra class to parse the format string and
> then guess the correct type.
>
> I guess we can implement something similar to this data formatter
> class in POI:http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFDataF...
Reply all
Reply to author
Forward
0 new messages