画像やグラフが含まれる XLS ファイルを PDF ドキュメントに変換する
Contents
[
Hide
]
Aspose.Cellsは、画像やチャートを含むXLSファイルをPDFドキュメントに変換するサポートがあります。Aspose.Cells for .NETはスプレッドシートをPDFに変換するために独立して動作できます。 Aspose.PDF for .NETは変換に必要ありません。そのため、大きなExcelファイル、例えば、画像やチャート、その他の描画オブジェクトを含むファイルも迅速かつ効率的に変換できます。
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
try | |
{ | |
// Get the template excel file path. | |
string designerFile = dataDir + "SampleInput.xls"; | |
// Specify the pdf file path. | |
string pdfFile = dataDir + "Output.out.pdf"; | |
// Open the template excel file | |
Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(designerFile); | |
// Save the pdf file. | |
wb.Save(pdfFile, SaveFormat.Pdf); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine(e.Message); | |
Console.ReadLine(); | |
} |
スプレッドシートに数式が含まれている場合は、PDF にレンダリングする直前に Workbook.CalculateFormula メソッドを呼び出すことが最適です。これにより、数式に依存する値が再計算され、正しい値が PDF にレンダリングされます。