我有一个xml文件和一个样式表,可以用xml数据完美地填充现有的excel(.xls)文件。但是如果我在给定的excel文件中有多个工作表,(除了要填充的第一个选项卡之外的所有剩余选项卡)在样式表转换后都会消失。
我认为样式表中需要提及一些内容 - 只更改第一张excel表吗?
我正在使用java.xml.transform包让样式表发挥作用。
示例代码为:
StreamSource stylesource = new StreamSource(stylesheet);
Transformer transformer = TransformerFactory.newInstance().newTransformer( stylesource );
Source source = new DOMSource( document );
Result outputTarget = new StreamResult( new File( outputFile ) );
transformer.transform( source, outputTarget );
如果需要,我的样式表的起始行如下:
<xsl:stylesheet version="1.0" xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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">