rabanti-github / PicoXLSX

PicoXLSX is a small .NET / C# library to create XLSX files (Microsoft Excel 2007 or newer) in an easy and native way
MIT License
52 stars 13 forks source link

Setting the value type in the Cell constructors doesn't work #7

Closed JohanLindvall closed 6 years ago

JohanLindvall commented 6 years ago

The value type is always "guessed" in the base Cell constructor, overriding what the user chooses.

Fixed in https://github.com/rabanti-github/PicoXLSX/pull/6.

rabanti-github commented 6 years ago

I withdrew release 2.3.2 and will merge this changes with the previous fix.

I deal with that this evening. Please let me know, if you find further issues or missing features.

Thank you in advance.

JohanLindvall commented 6 years ago

Thanks, we will be testing and using your library in the coming days.

rabanti-github commented 6 years ago

Supported are now:

The constructors of Cell do now only perform a auto-casting if Type set to DEFAULT (since this is an internal type and not existing in Excel). Therefore, if you define:

decimal dcVal = 1.223m;
Cell c = new Cell(dcVal, Cell.CellType.NUMBER);

... the type is kept at CellType.NUMBER. However, it is recommend to use AddCell() or AddNextCell(), since no type must be specified there. Is this the behavior you looked for? I assume you had problems that the decimal type was casted to a string. If you intend to store other types than the primitive data types, strings or DateTime objects into cells, I have too look into the LowLevel methods, since Excel is quite picky when it comes to wrong casted data.

Ist this state OK for you?

JohanLindvall commented 6 years ago

Thanks, this looks OK.