2009-01-13 140 views
0

在Calc中,我将一个单元格值设置为“2006/10/03 13:33:55.448”,Calc说它是标准格式。我与Java这样做的,我想设置的格式 “DD.MM.YY HH:MM:SS AM/PM”:更改日期格式

XNumberFormatTypes xFormatTypes = (XNumberFormatTypes) UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats); 
int myDateFormat = xNumberFormats.addNew("DD.MM.YY HH:MM:SS AM/PM", defaultLocale); 
XPropertySet cellRangePropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, cellRange); 
cellRangePropSet.setPropertyValue("NumberFormat", new Integer(myDateFormat)); 

但细胞STIL看起来是一样的。我是否必须刷新范围以便单元显示“03.10.06 01:33:55 PM”?

回答

1

不,我没有在我的任何项目中这样做。 问题是我在Calc中导入了一个csv文件,并指定日期列的类型为Standard。然后我将它更改为Date(YY/MM/DD),代码奇迹般地工作。 :)