ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Setting Excel cell format (https://www.excelbanter.com/excel-worksheet-functions/205202-setting-excel-cell-format.html)

Sasha

Setting Excel cell format
 
I need to export data to an excel file programmatically. Date includes time
in form of min:sec and full date with time. IRange::PutValue2 accepts variant
and if I pass COleVaraint created from COleDateTime I have excel show value
as a double "39726.47661". I need to manually right click and select "Format
Cells..." menu, then select Date or time Category and then the value is shown
as I want. How can I do all this programmatically so that value is shown as
date and time initially?

Sheeloo[_2_]

Setting Excel cell format
 
This is the way Excel internally stores dates. You need to
1. Set the format in your import program if you can or
2. Have a macro to do that or
3. Convert the dates before importing to the format you want but then they
will be treated as text and not dates in Excel.

"Sasha" wrote:

I need to export data to an excel file programmatically. Date includes time
in form of min:sec and full date with time. IRange::PutValue2 accepts variant
and if I pass COleVaraint created from COleDateTime I have excel show value
as a double "39726.47661". I need to manually right click and select "Format
Cells..." menu, then select Date or time Category and then the value is shown
as I want. How can I do all this programmatically so that value is shown as
date and time initially?



All times are GMT +1. The time now is 05:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com