LoginSignup
0
1

More than 3 years have passed since last update.

Java XMLを Excelに変換

Posted at

XMLは、ファイルにデータを書き込むときの記述形式の1つで、種類の異なるソフトウェア間でデータを交換するための形式として利用されます。今回はSpire.XLS for Javaというライブラリを利用して、XMLを Excelに変換する方法を紹介します。

 下準備

1.E-iceblueの公式サイトからFree Spire. XLS for Java無料版をダウンロードしてください。

f:id:lendoris:20210428154326p:plain

2.IDEを起動して新規プロジェクトを作成してから、インストールされたファイルにあった相応しいSpire. XLS.jarを参照に追加してください。

f:id:lendoris:20210428154341p:plain

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);
    }
}

 f:id:lendoris:20210428155121p:plain

 

 

 

 

 

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1