正在尝试从excel xml文件获取有效时间到OpenOfficeCalc

正在尝试从excel xml文件获取有效时间到OpenOfficeCalc,xml,excel,openoffice-calc,Xml,Excel,Openoffice Calc,xml文件如下所示:- <?xml version="1.0" encoding="iso-8859-1" ?> <?mso-application progid="Excel.Sheet" ?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-mi

xml文件如下所示:-

<?xml version="1.0" encoding="iso-8859-1" ?>
<?mso-application progid="Excel.Sheet" ?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" >
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office" />
<Styles >
<Style ss:ID="Default" ss:Name="Normal" >
<Borders />
<Interior />
<NumberFormat />
<Protection />
<Alignment ss:Vertical="Bottom" />
<Font />
</Style>
<Style ss:ID="s21" >
<NumberFormat ss:Format="dd\/MM\/yyyy HH:mm:ss" />
</Style>
<Style ss:ID="s23" >
<NumberFormat ss:Format="0.00000" />
</Style>
</Styles>
<Worksheet ss:Name="Sheet1" >
<Table ss:ExpandedColumnCount="5" ss:ExpandedRowCount="1040" >
<Row >
<Cell >
<Data ss:Type="String" >Date</Data>
</Cell>
<Cell >
<Data ss:Type="String" >Open</Data>
</Cell>
<Cell >
<Data ss:Type="String" >Close</Data>
</Cell>
<Cell >
<Data ss:Type="String" >High</Data>
</Cell>
<Cell >
<Data ss:Type="String" >Low</Data>
</Cell>
</Row>
<Row >
<Cell ss:StyleID="s21" >
<Data ss:Type="DateTime" >2016-07-02T02:49:00</Data>
</Cell>
<Cell ss:StyleID="s23" >
<Data ss:Type="Number" >0.74900</Data>
</Cell>
<Cell ss:StyleID="s23" >
<Data ss:Type="Number" >0.74800</Data>
</Cell>
<Cell ss:StyleID="s23" >
<Data ss:Type="Number" >0.74900</Data>
</Cell>
<Cell ss:StyleID="s23" >
<Data ss:Type="Number" >0.74800</Data>
</Cell>
</Row>
请注意,时间始终为00:00:00,但xml文件包含正确的时间

我只能更改xml文件或更改Open Office Calc中的设置

那么,我可以更改什么来获得正确的时间值以显示在Open Office Calc中

注意:我有“Note Tab Light”,它允许我使用正则表达式,因此修改xml文件是可行的

非常感谢
Peter

如果
OpenOffice
LibreOffice
尝试导入不同于其自身XML的XML文件,则它们将使用XML导入筛选器。您可以通过
工具-XML过滤器设置设置这些过滤器

MS Excel 2003 XML
的默认导入筛选器包含以下XSLT:

            <xsl:when test="ss:Data/@ss:Type = 'DateTime'">
                <xsl:choose>
                    <xsl:when test="(contains( $data-format, 'Date') or contains($data-format,'y') or contains($data-format,'g') or contains($data-format,'d') or contains($data-format,'e') or starts-with( substring( ss:Data, 11), 'T00:00:00.000' ) ) and (not (contains( $data-format, 'Time') ) )">
                        <xsl:attribute name="office:value-type">date</xsl:attribute>
                        <xsl:attribute name="office:date-value">
                            <xsl:value-of select="substring-before(ss:Data, 'T')"/>
                        </xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:attribute name="office:value-type">time</xsl:attribute>
                        <xsl:attribute name="office:time-value">
                            <xsl:value-of select="concat('P',substring(ss:Data, 11, 3), 'H', substring(ss:Data, 15, 2), 'M', substring(ss:Data, 18,2), 'S')"/>
                        </xsl:attribute>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>

日期
时间
这意味着过滤器可以选择日期部分,也可以选择时间部分,但不能同时选择两者

可以对XSLT进行如下更改:

            <xsl:when test="ss:Data/@ss:Type = 'DateTime'">
                <xsl:choose>
                    <xsl:when test="(contains( $data-format, 'Date') or contains($data-format,'y') or contains($data-format,'g') or contains($data-format,'d') or contains($data-format,'e') or starts-with( substring( ss:Data, 11), 'T00:00:00.000' ) ) and (not (contains( $data-format, 'Time') ) )">
                        <xsl:attribute name="office:value-type">date</xsl:attribute>
                        <xsl:attribute name="office:date-value">
                        <!--    <xsl:value-of select="substring-before(ss:Data, 'T')"/> -->
                            <xsl:value-of select="ss:Data"/>
                        </xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:attribute name="office:value-type">time</xsl:attribute>
                        <xsl:attribute name="office:time-value">
                            <xsl:value-of select="concat('P',substring(ss:Data, 11, 3), 'H', substring(ss:Data, 15, 2), 'M', substring(ss:Data, 18,2), 'S')"/>
                        </xsl:attribute>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>

日期
时间
但为此,必须更改所有OpenOffice应用程序中的
share\xslt\import\spreadsheetml\spreadsheetml2oo.xsl
,这些应用程序应该导入
MS Excel 2003 XML
。所以这是不可行的

人们可能希望Apache能够更正
MSExcel2003XML
的默认导入过滤器。但他们会吗

因此,总而言之,目前不可能从
MSExcel2003XML
OpenOffice
获取
DateTime


但是
MSExcel2003XML
相当陈旧。为什么需要使用这种旧的XML?为什么不简单地使用像
BIFF
*.xls
)或
Office OpenXML
*.xlsx
)这样的真正的Excel呢?

如果
OpenOffice
LibreOffice
尝试导入与自己的XML不同的XML文件,那么他们正在使用XML导入过滤器。您可以通过
工具-XML过滤器设置设置这些过滤器

MS Excel 2003 XML
的默认导入筛选器包含以下XSLT:

            <xsl:when test="ss:Data/@ss:Type = 'DateTime'">
                <xsl:choose>
                    <xsl:when test="(contains( $data-format, 'Date') or contains($data-format,'y') or contains($data-format,'g') or contains($data-format,'d') or contains($data-format,'e') or starts-with( substring( ss:Data, 11), 'T00:00:00.000' ) ) and (not (contains( $data-format, 'Time') ) )">
                        <xsl:attribute name="office:value-type">date</xsl:attribute>
                        <xsl:attribute name="office:date-value">
                            <xsl:value-of select="substring-before(ss:Data, 'T')"/>
                        </xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:attribute name="office:value-type">time</xsl:attribute>
                        <xsl:attribute name="office:time-value">
                            <xsl:value-of select="concat('P',substring(ss:Data, 11, 3), 'H', substring(ss:Data, 15, 2), 'M', substring(ss:Data, 18,2), 'S')"/>
                        </xsl:attribute>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>

日期
时间
这意味着过滤器可以选择日期部分,也可以选择时间部分,但不能同时选择两者

可以对XSLT进行如下更改:

            <xsl:when test="ss:Data/@ss:Type = 'DateTime'">
                <xsl:choose>
                    <xsl:when test="(contains( $data-format, 'Date') or contains($data-format,'y') or contains($data-format,'g') or contains($data-format,'d') or contains($data-format,'e') or starts-with( substring( ss:Data, 11), 'T00:00:00.000' ) ) and (not (contains( $data-format, 'Time') ) )">
                        <xsl:attribute name="office:value-type">date</xsl:attribute>
                        <xsl:attribute name="office:date-value">
                        <!--    <xsl:value-of select="substring-before(ss:Data, 'T')"/> -->
                            <xsl:value-of select="ss:Data"/>
                        </xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:attribute name="office:value-type">time</xsl:attribute>
                        <xsl:attribute name="office:time-value">
                            <xsl:value-of select="concat('P',substring(ss:Data, 11, 3), 'H', substring(ss:Data, 15, 2), 'M', substring(ss:Data, 18,2), 'S')"/>
                        </xsl:attribute>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>

日期
时间
但为此,必须更改所有OpenOffice应用程序中的
share\xslt\import\spreadsheetml\spreadsheetml2oo.xsl
,这些应用程序应该导入
MS Excel 2003 XML
。所以这是不可行的

人们可能希望Apache能够更正
MSExcel2003XML
的默认导入过滤器。但他们会吗

因此,总而言之,目前不可能从
MSExcel2003XML
OpenOffice
获取
DateTime

但是
MSExcel2003XML
相当陈旧。为什么需要使用这种旧的XML?为什么不简单地使用像
BIFF
*.xls
)或
officeopenxml
*.xlsx
)这样的真正的Excel呢