ブックでのカスタム番号の小数点とグループの区切り記号を指定する
Microsoft Excelでは、その他のExcelオプション から 詳細設定 を使用せずに、カスタムの小数点および千の区切り記号を指定できます。次のスクリーンショットでは、その手順が示されています。
Aspose.Cells for Python via .NETは、数値のフォーマット/解析にカスタムセパレーターを設定するための WorkbookSettings.number_decimal_separator と WorkbookSettings.number_group_separator プロパティを提供します。
Microsoft Excelを使用してカスタムセパレータを指定する
次のスクリーンショットは、詳細設定 タブを示し、カスタムセパレータ を指定するセクションを強調しています。
Aspose.Cells for Python via .NETを使用したカスタムセパレーターの指定
以下のサンプルコードは、Aspose.Cells for Python via .NET APIを使ったカスタムセパレーターの指定方法を示しています。これは、カスタムの数値小数点とグループセパレーターをそれぞれドットとスペースに設定しています。
C#コードでカスタム数値の10進セパレータとグループセパレータを指定
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
workbook = Workbook() | |
# Specify custom separators | |
workbook.settings.number_decimal_separator = '.' | |
workbook.settings.number_group_separator = ' ' | |
worksheet = workbook.worksheets[0] | |
# Set cell value | |
cell = worksheet.cells.get("A1") | |
cell.put_value(123456.789) | |
# Set custom cell style | |
style = cell.get_style() | |
style.custom = "#,##0.000;[Red]#,##0.000" | |
cell.set_style(style) | |
worksheet.auto_fit_columns() | |
# Save workbook as pdf | |
workbook.save(dataDir + "CustomSeparator_out.pdf") |