XlS file with date format php

风格不统一 提交于 2020-01-25 10:53:04

问题


I have created a xls file with following row,

  <Row>
   <Cell><Data ss:Type="String">1761601 21:36</Data></Cell>
   <Cell><Data ss:Type="DateTime">2014-08-20</Data></Cell>
   <Cell><Data ss:Type="Number">12</Data></Cell>
 </Row>

But, <Cell><Data ss:Type="DateTime">2014-08-20</Data></Cell> will create a cell with value 41871 ,Why? How can i show that value in date format?


回答1:


IN the <style> section add

   <Style ss:ID="s22">
   <NumberFormat ss:Format="yyyy\-mm\-dd"/>
   </Style>

then mark your cell with the style:

 <Cell ss:StyleID="s22"><Data ss:Type="DateTime">2014-08-20</Data></Cell>

Try this it should work!!

DO LET ME KNOW IF IT WORKS




回答2:


Well Hello ,

I will show you how You got 41871 . If u understand u will get the problem ::

First LETS Simply your Problem and use excel

PLS CLICK ON LINKS TO SEE IMAGES

What U NEED!

Open below Link in New Tab

https://drive.google.com/folderview?id=0BxWpasnS1lMRZm5zcnB6UHdUUmM&usp=sharing

Notice now the Data Type is taken as Date .... So everything is correct till now

Now lets Enter the Same Date in another cell ... Notice here also the Data Type is DATE

Now Lets Change it to General ... AND BINGO

You get 41871.... Did u get the reason why its showing 41871.....

Now try using this ...

<Data ss:Type="Date">2014-08-20 : Date - SHORT_DATE</Data>

AND IF IT WORKS GREAT!!!!!!!!! EnJOY

ANDD

A final word on working with Dates

Dates are always problematic,

US uses a date format that is different to most of the rest of the world. Specifically:

  • The US refers to dates in the format "month, day, year"
  • The rest of the world (ROW) refers to dates in the format "day, month, year"

That means that when you're working with dates. You need to know which date format your computer is set up to use. Otherwise you can get some strange behaviour - and errors.



来源:https://stackoverflow.com/questions/25419077/xls-file-with-date-format-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!