Excel を Pdf、画像、その他の形式に変換する

Excel ワークブックを PDF に変換

PDF ファイルは、組織、政府部門、および個人の間でドキュメントを交換するために広く使用されています。これは標準的なドキュメント形式であり、ソフトウェア開発者は、Microsoft Excel ファイルを PDF ドキュメントに変換する方法を見つけるように求められることがよくあります。

Aspose.Cells は、Excel ファイルの PDF への変換をサポートし、変換で高い視覚的忠実度を維持します。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Instantiate the Workbook object
// Open an Excel file
Workbook workbook = new Workbook("Book1.xlsx");
// Save the document in PDF format
workbook.Save("output.pdf");

Excel ワークブックを JPG に変換

Aspose.Cells は、Excel ファイルの JPG への変換をサポートしています。 次のコード例は、ワークブックを JPG として保存する方法を示しています。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//Convert workbook to JPG image.
book.Save("Image1.jpg");

Excel ワークブックを画像に変換

Aspose.Cells は、Excel ファイルの画像への変換をサポートしています。 次のコード例は、ワークブックを画像として保存する方法を示しています。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//Convert workbook to BMP image.
book.Save("Image1.bmp");
//Convert workbook to JPG image.
book.Save("Image1.jpg");
//Convert workbook to Png image.
book.Save("Image1.png");
//Convert workbook to EMF image.
book.Save("Image1.emf");
//Convert workbook to GIF image.
book.Save("Image1.gif");

Excel ワークブックを XPS に変換する

XPS ドキュメント形式は、ドキュメントのレイアウトと各ページの外観を定義する構造化された XML マークアップと、ドキュメントの配布、アーカイブ、レンダリング、処理、および印刷のためのレンダリング ルールで構成されます。

XPS のマークアップ言語は XAML のサブセットであり、XAML を使用して Windows プレゼンテーション ファウンデーション (WPF) プリミティブをマークアップし、ドキュメントにベクター グラフィック要素を組み込むことができます。使用される要素は、パスおよびその他のジオメトリ プリミティブの観点から記述されます。

実際、XPS ファイルは、ドキュメントを構成するファイルを含む、Open Packaging Conventions を使用した Unicode ZIP アーカイブです。これらには、各ページの XML マークアップ ファイル、テキスト、埋め込みフォント、ラスター イメージ、2D ベクター グラフィックス、およびデジタル著作権管理情報が含まれます。 XPS ファイルの内容は、ZIP ファイルをサポートするアプリケーションで開くだけで調べることができます。

Aspose.Cells 6.0.0、Microsoft Excel から XPS への変換に対応しました。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open an Excel file
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(dataDir + "Book1.xls");
// Get the first worksheet
Aspose.Cells.Worksheet sheet = workbook.Worksheets[0];
// Apply different Image and Print options
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
// Set the Format
options.SaveFormat = SaveFormat.Xps;
// Render the sheet with respect to specified printing options
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, options);
// Save
sr.ToImage(0, dataDir + "out_printingxps.out.xps");
// Export the whole workbook to XPS
workbook.Save(dataDir + "out_whole_printingxps.out.xps", new XpsSaveOptions());

Excel を Ods、Sxc、Fods に変換 (OpenOffice / LibreOffice Calc)

Aspose.Cells は、Excel ファイルを Ods、Sxc、および Fods ファイルに変換することをサポートしています。以下のコード例は、テンプレートOds、Sxc、および Fods ファイルに。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("book1.xlsx");
// Save as ods file
workbook.Save("Out.ods");
// Save as sxc file
workbook.Save("Out.sxc");
// Save as fods file
workbook.Save("Out.fods");

Excel ワークブックを MHTML ファイルに変換する

MHTML は、通常の HTML を外部リソース (つまり、画像、アニメーション、オーディオなど、通常リンクされるコンテンツ) と 1 つのファイルに結合します。これらは、ファイル拡張子が .mht の電子メールに使用されます。

Aspose.Cells は、MHTML ファイルの読み取りと書き込みをサポートします。

次のコード例は、ワークブックを MHTML ファイルとして保存する方法を示しています。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Specify the file path
string filePath = dataDir + "Book1.xlsx";
// Specify the HTML Saving Options
HtmlSaveOptions sv = new HtmlSaveOptions(SaveFormat.MHtml);
// Instantiate a workbook and open the template XLSX file
Workbook wb = new Workbook(filePath);
// Save the MHT file
wb.Save(filePath + ".out.mht", sv);

Excel ワークブックを HTML に変換する

Aspose.Cells API は、スプレッドシートを HTML 形式にエクスポートするためのサポートを提供します。この目的のために、Aspose.Cells は**HtmlSaveOptions**出力HTMLのいくつかの側面を制御する柔軟性を提供するクラス。

次のコード例は、ワークブックを HTML ファイルとして保存する方法を示しています。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Specify the file path
string filePath = dataDir + "sample.xlsx";
// Load your sample excel file in a workbook object
Workbook wb = new Workbook(filePath);
// Save it in HTML format
wb.Save(dataDir + "ConvertingToHTMLFiles_out.html", SaveFormat.Html);

HTML の画像設定の設定

8.0.2から、Aspose.Cellsが公開されました**ImageOptions**のために**HtmlSaveOptions**クラスを使用すると、開発者はスプレッドシートを HTML 形式で保存するときに画像の設定を指定できます。

以下は、適用できる画像設定の一部の詳細です。

  • 画像タイプ: 画像の種類を指定します。グラフを含むすべての図形は、出力 HTML でイメージとしてレンダリングされることに注意してください。
  • SmoothingMode: 塗りつぶされた領域の線、曲線、エッジのアンチエイリアシングを指定します。
  • TextRenderingHint: テキスト レンダリングの品質を指定します。
  • 品質 : 画像の品質を 0 ~ 100 で指定します。**画像タイプ**jpegと指定されています。
  • 垂直解像度: イメージの垂直方向の解像度をドット/インチで取得または設定します。
  • **水平解像度**イメージの水平方向の解像度をドット/インチで取得または設定します。
  • TiffCompression : イメージの圧縮タイプを取得または設定します。**画像タイプ**は Tiff として指定されます。
  • 透明: ImageFormat が Png として指定されている場合、画像の背景を透明にするかどうかを示します。

以下のコードは、使用方法を示しています**HtmlSaveOptions.ImageOptions**さまざまな設定を指定します。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Specify the file path
string filePath = dataDir + "Book1.xlsx";
// Load a spreadsheet to be converted
Workbook book = new Workbook(filePath);
// Create an instance of HtmlSaveOptions
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.Html);
// Set the ImageFormat to PNG
saveOptions.ImageOptions.ImageType = Drawing.ImageType.Png;
// Set SmoothingMode to AntiAlias
saveOptions.ImageOptions.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// Set TextRenderingHint to AntiAlias
saveOptions.ImageOptions.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
// Save spreadsheet to HTML while passing object of HtmlSaveOptions
book.Save( dataDir + "output.html", saveOptions);

Excel ワークブックを Markdown に変換する

Aspose.Cells API は、スプレッドシートを Markdown 形式にエクスポートするためのサポートを提供します。アクティブなワークシートを Markdown にエクスポートするには、次を渡します。**SaveFormat.Markdownの 2 番目のパラメータとしてWorkbook.Save方法。使用することもできますMarkdownSaveOptions**クラスを使用して、ワークシートを Markdown にエクスポートするための追加設定を指定します。

次のコード例は、アクティブなワークシートを Markdown にエクスポートする方法を示しています。**SaveFormat.Markdown**列挙メンバー。をご覧ください出力Markdownファイル参照用のコードによって生成されます。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open the template file
Workbook workbook = new Workbook(sourceDir + "Book1.xlsx");
// Save as Markdown
workbook.Save(outputDir + "Book1.md", SaveFormat.Markdown);

Excel ワークブックを JSON に変換

Aspose.Cells は、ワークブックを Json (JavaScript Object Notation) ファイルに変換することをサポートしています。

次のコード例は、アクティブなワークシートを Json にエクスポートする方法を示しています。SaveFormat.Json列挙メンバー。変換するコードを参照してくださいソースファイル出力Jsonファイル参照用のコードによって生成されます。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
// convert the workbook to json file.
workbook.Save(dir + "book1.json");

Excel を XML に変換する

Aspose.Cells は、ブックを Excel 2003 スプレッドシート XML およびプレーン XML データに変換することをサポートしています。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//Save as Excel 2003 Spreadsheet XML
workbook.Save("Spreadsheet.xml");
//Save as plain XML data
XmlSaveOptions xmlSaveOptions = new XmlSaveOptions();
workbook.Save("data.xml", xmlSaveOptions);

Excel ワークブックを TIFF に変換

Aspose.Cells は、ブックを TIFF ファイルに変換することをサポートします。

以下のコード スニペットは、Excel を TIFF に変換する方法を示しています。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//save file to tiff
book.Save("out.tiff");

Excel ワークブックを DOCX に変換

Aspose.Cells API は、スプレッドシートを DOCX 形式に変換するためのサポートを提供します。ワークブックを DOCX にエクスポートするには、次を渡します。SaveFormat.Docxの 2 番目のパラメータとしてWorkbook.Save方法。使用することもできますDocxSaveOptionsクラスを使用して、ワークシートを DOCX にエクスポートするための追加設定を指定します。

次のコード例は、アクティブなワークシートを DOCX にエクスポートする方法を示しています。SaveFormat.Docx列挙メンバー。をご覧ください出力 DOCX ファイル参照用のコードによって生成されます。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open the template file
Workbook workbook = new Workbook(sourceDir + "Book1.xlsx");
// Save as Markdown
workbook.Save(outputDir + "Book1.docx", SaveFormat.Docx);

Excel ワークブックを PPTX に変換

Aspose.Cells API は、スプレッドシートを PPTX 形式に変換するためのサポートを提供します。ワークブックを PPTX にエクスポートするには、次を渡します。SaveFormat.Pptxの 2 番目のパラメータとしてWorkbook.Save方法。使用することもできますPptxSaveOptionsクラスを使用して、ワークシートを PPTX にエクスポートするための追加設定を指定します。

次のコード例は、アクティブなワークシートを PPTX にエクスポートする方法を示しています。SaveFormat.Pptx列挙メンバー。をご覧ください出力 PPTX ファイル参照用のコードによって生成されます。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open the template file
Workbook workbook = new Workbook(sourceDir + "Book1.xlsx");
// Save as Markdown
workbook.Save(outputDir + "Book1.pptx", SaveFormat.Pptx);

先行トピック