当NumberFormat设置为"MM/dd/yyyy"时面临问题 [英] Facing issue when NumberFormat is set as "MM/dd/yyyy"
本文介绍了当NumberFormat设置为"MM/dd/yyyy"时面临问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Microsoft.Office.Interop.Excel dll生成Excel文件.将NumberFormat设置为"MM/dd/yyyy"时出现问题.当日期小于1900时,将引发异常.
我可以理解,DateTime格式允许该列将日期保存到1900年.现在如何更改该格式以将日期保存到小于1900年?
请帮忙.
谢谢,
Srikanth
解决方案
也许Excel不支持早于1900年的日期...您用谷歌搜索了吗?
编辑==============
我在Google上进行了搜索,发现Excel接受的最早日期是1900年1月1日.你不走运,Sparky.这是我在以下位置找到信息的链接:
http://www.ozgrid.com/Excel/free-training/excel- lesson-13-basic.htm [ ^ ]
向下滚动到标有"Excel日期和时间"的部分.
您可能无论如何都不应该使用1900年之前的日期,而Excel错误地认为1900年是leap年,因此日期序列仍然是该年的年份. />Hi,
I''m generating an Excel file using Microsoft.Office.Interop.Excel dll. I have an issue when I set the NumberFormat as "MM/dd/yyyy". When the date is less than 1900 it throws an exception.
I could understand that the DateTime format allows the column to hold date till 1900. Now how shall I change the format to hold date less than 1900?
Please help.
Thanks,
Srikanth解决方案Maybe Excel doesn''t support dates earlier than 1900... have you googled it?
EDIT ==============
I googled it, and found out that the earliest possible date Excel will accept is 01/01/1900. You''re out of luck, Sparky. Here''s the link I found the info at:
http://www.ozgrid.com/Excel/free-training/excel-lesson-13-basic.htm[^]
Scroll down to the section labeled "Excel Dates and Times".
You probably should not use a date before 1900 anyway and Excel mistakenly thinks 1900 is a leap year, so the date serial is off that year anyway.
这篇关于当NumberFormat设置为"MM/dd/yyyy"时面临问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文