XMLは、ファイルにデータを書き込むときの記述形式の1つで、種類の異なるソフトウェア間でデータを交換するための形式として利用されます。今回はSpire.XLS for Javaというライブラリを利用して、XMLを Excelに変換する方法を紹介します。
下準備
1.E-iceblueの公式サイトからFree Spire. XLS for Java無料版をダウンロードしてください。
2.IDEを起動して新規プロジェクトを作成してから、インストールされたファイルにあった相応しいSpire. XLS.jarを参照に追加してください。
```JAVA import com.spire.xls.*;public class xmltoexcel {
public static void main(String[] args) {
//xmlファイルをロードします。
Workbook wb = new Workbook();
wb.loadFromXml("test.xml");
//xlsxで保存します。
wb.saveToFile("xmltoExcel.xlsx",FileFormat.Version2013);
//xlsで保存します。
wb.saveToFile("xmltoExcel.xls",FileFormat.Version97to2003);
}
}
<p><strong> <img src="https://cdn-ak.f.st-hatena.com/images/fotolife/l/lendoris/20210428/20210428155121.png" alt="f:id:lendoris:20210428155121p:plain" title="" class="hatena-fotolife" itemprop="image" /></strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>