ワークブック内の未使用のスタイルを削除する
Contents
[
Hide
]
Excelファイル内の未使用のスタイルは、ストレージを占有するだけでなく、PDF、HTMLなどの異なる形式での変換時にパフォーマンスの問題を引き起こします。Aspose.Cellsは、Workbook.removeUnusedStyles()を提供して、ワークブック内の未使用のスタイルをすべて削除します。
ワークブック内の未使用のスタイルを削除する
以下のコードは、Workbook.removeUnusedStyles()の使用方法を説明しています。コードは、提供されたリンクからダウンロードできるテンプレートExcelファイルをロードします。このファイルには AsposeStyle という未使用のスタイルが含まれており、コードの実行後にこのスタイルと他の未使用のスタイルがすべて削除されます。詳しい説明については、以下のスクリーンショットを参照してください。
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-Java | |
String dataDir = Utils.getDataDir(RemoveUnusedStyles.class); | |
String inputPath = dataDir + "Styles.xlsx"; | |
String outputPath = dataDir + "Output.xlsx"; | |
Workbook workbook = new Workbook(inputPath); | |
workbook.removeUnusedStyles(); | |
workbook.save(outputPath); | |
System.out.println("File saved " + outputPath); |