ワークブックのレンダリング用に個々またはプライベートなフォントセットを指定する

可能な使用シナリオ

通常、すべてのワークブックにフォントディレクトリやフォントのリストを指定しますが、時々、ワークブックごとに個別またはプライベートなフォントセットを指定する必要があります。Aspose.Cells は、ワークブックごとに個別またはプライベートなフォントセットを指定するために使用できる IndividualFontConfigs クラスを提供しています。

ワークブックのレンダリング用に個々またはプライベートなフォントセットを指定する

以下のサンプルコードは、IndividualFontConfigs クラスを使用して指定された個別またはプライベートなフォントと共に サンプル Excel ファイル をロードします。また、コード内で使用されている サンプルフォント と、それによって生成された output PDF も参照してください。出力された PDF のスクリーンショットは、フォントが正常に見つかった場合の外観を示しています。

todo:image_alt_text

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Path of your custom font directory.
string customFontsDir = "C:\\TempDir\\CustomFonts";
// Specify individual font configs custom font directory.
IndividualFontConfigs fontConfigs = new IndividualFontConfigs();
// If you comment this line or if custom font directory is wrong or
// if it does not contain required font then output pdf will not be rendered correctly.
fontConfigs.SetFontFolder(customFontsDir, false);
// Specify load options with font configs.
LoadOptions opts = new LoadOptions(LoadFormat.Xlsx);
opts.FontConfigs = fontConfigs;
// Load the sample Excel file with individual font configs.
Workbook wb = new Workbook("sampleSpecifyIndividualOrPrivateSetOfFontsForWorkbookRendering.xlsx", opts);
// Save to PDF format.
wb.Save("outputSpecifyIndividualOrPrivateSetOfFontsForWorkbookRendering.pdf", SaveFormat.Pdf);