Javaによるファイル形式の変換

他のソフトウェアを使用せずに、Microsoft ® Officeドキュメント、PDF、画像、HTML、およびその他の複数のファイルを変換します。

 

[Java Total Library](https://products.aspose.com/total/java/)は、ドキュメント操作ソリューションをゼロから開発したり、既存のアプリケーションを拡張してドキュメント管理を簡単に処理したりすることを高速化します。 APIは、Microsoft Officeドキュメントを作成、編集、変換するだけでなく、PDF、HTML、画像TIFF、JPG、PNG、BMP、SVG、電子メールファイル、ビデオ形式、3D、CADなどを処理します。これは、Java J2SE、J2EE、J2MEアプリケーション内にソフトウェアの依存関係がないドキュメント管理および操作ソリューションAPIのコレクションです。プログラマーは、Javaベースのアプリケーション内で最も一般的な形式を簡単に作成、更新、レンダリング、印刷、および変換できます。

WordからExcelへの変換

Total APIは、Microsoft Word形式の相互変換だけでなく、WordからExcel、PDF、HTML、画像、EPUB、Markdown、XPSへの変換もサポートしています。変換のプロセスは簡単です。 WordからExcelへの変換の場合を考えてみましょう。 [Document](https://reference.aspose.com/words/java/com.aspose.words/Document)クラスを使用してMicrosoft Wordファイルをロードし、[Save method](https: //apireference.aspose.com/words/java/com.aspose.words/Document#save(java.lang.String,com.aspose.words.SaveOptions))。次に、[Workbook](https://reference.aspose.com/cells/java/com.aspose.cells/Workbook)クラスを使用して変換されたHTMLドキュメントを開き、[Save](https:/ /apireference.aspose.com/cells/java/com.aspose.cells/workbook#save(java.lang.String,%20com.aspose.cells.SaveOptions))メソッド。 開発者は[WordをPDFに変換](https://products.aspose.com/words/java/conversion/word-to-pdf/)することもできます。

Java WordからExcelへの変換

// supports DOC, DOT, DOCX, DOCM, DOTX, DOTM, RTF, WordML, MOBI, ODT, and OTT input file formats
// load DOCX with an instance of Document
Document document = new Document("template.docx");
// call Save method while passing SaveFormat.HTML
document.save("html_output.html",SaveFormat.HTML);
// load the HTML file in an instance of Workbook
Workbook book = new Workbook("html_output.html");
// supports XLS, XLSX, XLSB, XLSM, XLT, XLT, XLTM, XLAM, CSV, TSV, ODS, DIF, SXC, and FODS file formats
// save HTML as XLSX
book.save("output.xlsx", SaveFormat.AUTO);
 

PDFを画像に変換する

APIは、PDFをJPEG2000、EMZ、WMZ、TGA、PSD、DXF、WMF、SVGZ、APNG、DICOM、Powerpoint、Excelなどの形式の画像に変換することをサポートしています。 PDFから画像への変換では、JPG画像をターゲットファイルと考えてみましょう。プロセスは、Documentクラスを使用してPDFファイルをロードし、[JpegDeviceクラス](https://reference.aspose.com/pdf/java/aspose.pdf.devices/jpegdevice)オブジェクトを初期化し、[プロセス](https ://apireference.aspose.com/pdf/java/aspose.pdf.devices.pagedevice/process/methods/1)メソッド [Image](https://reference.aspose.com/imaging/java/aspose.imaging/image)クラスを使用してJPEGファイルをロードし、最後にSaveメソッドを呼び出します。

Java PDF to Image Conversion

// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats
// load PDF with an instance of Document
Document document = new Document("input.pdf");
// create an object of JpegDevice
JpegDevice renderer = new JpegDevice();
// convert first of a particular PDF page to JPEG format
renderer.process(document.getPages().get_Item(1), "output.jpeg");
// load JPEG file
Image image = Image.Load("output.jpeg");
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats
// save JPEG to PSD file format
image.save("output.psd", new PsdOptions());
 

PowerPointをExcelファイルに変換する

Microsoft PowerPointファイルを、Excel Word、MHTML、メインのAspose.Total forJavaAPIに含まれる関連するサブAPIなどのさまざまなファイルに変換します。 PowerPointファイルをExcelドキュメントに変換するプロセス、[プレゼンテーション](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation)クラスを使用してPowerPointファイルをロードし、PowerPointをHTMLに変換する[保存](https://reference.aspose.com/slides/java/com.aspose.slides/Presentation#save-java.lang.String-int-com.aspose.slides.ISaveOptions-)メソッドを使用します。次に、[Workbook](https://reference.aspose.com/cells/java/com.aspose.cells/Workbook)クラスを使用して変換されたHTMLドキュメントをロードし、[save](https:/ /apireference.aspose.com/cells/java/com.aspose.cells/workbook#save(java.lang.String,%20com.aspose.cells.SaveOptions))メソッド。 PowerPointからWordへの変換のコードもリストされています。

JavaPowerPointからExcelへの変換

// supports PPT, POT, PPS, PPTX, POTX, PPSX, PPTM, PPSM, and POTM input file formats
// instantiate a Presentation object that represents a PPT file
Presentation presentation = new Presentation("template.ppt");
// save the presentation as HTML
presentation.save("output.html", SaveFormat.Html);
// load the HTML file in an instance of Workbook
Workbook book = new Workbook("output.html");
// Supports XLS, XLSX, XLSB, XLSM, XLT, XLTX, XLTM, XLAM, CSV, TSV, TXT, MHTML, ODS, DIF, MARKDOWN, SXC, and FODS output file formats
// save HTML as XLS
book.save("output.xls", SaveFormat.Xls);

JavaPowerPointからWordへの変換

// supports POTM, POT, POTX, PPSM, PPS, PPSX, PPTM, PPT, and PPTX input file formats
// instantiate a Presentation object that represents a PPT file
Presentation presentation = new Presentation("input.ppt");
// save the presentation as HTML
presentation.save("htmlOutput.html", SaveFormat.Html);
// load HTML with an instance of Document
Document document = new Document("htmlOutput.html");
// supports DOC, DOCX, DOT, DOTM, DOTX, FLATOPC, ODT, OTT, RTF, TXT, WORDML, DOCM output file formats.
// save document in DOC format
document.save("output.doc",SaveFormat.Doc);