Excelファイルに格納する有効数字を指定する
Contents
[
Hide
]
考えられる使用シナリオ
デフォルトでは、Aspose.Cells は、有効桁数 15 桁のみを格納する MS-Excel とは異なり、Excel ファイル内に有効桁数 17 桁の double 値を格納します。を使用して、Aspose.Cells のデフォルトの動作を 17 桁から 15 桁に変更できます。CellsHelper.SignificantDigits財産。
Excelファイルに格納する有効数字を指定する
次のサンプル コードは、Aspose.Cells が 15 桁の有効数字を使用するように強制し、Excel ファイル内に double 値を格納します。を確認してください出力エクセルファイル.拡張子を .zip に変更して解凍すると、Excel ファイル内に有効数字が 15 桁しか格納されていないことがわかります。次のスクリーンショットは、CellsHelper.SignificantDigits出力 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); | |
//By default, Aspose.Cells stores 17 significant digits unlike | |
//MS-Excel which stores only 15 significant digits | |
CellsHelper.SignificantDigits = 15; | |
//Create workbook | |
Workbook workbook = new Workbook(); | |
//Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
//Access cell A1 | |
Cell c = worksheet.Cells["A1"]; | |
//Put double value, only 15 significant digits as specified by | |
//CellsHelper.SignificantDigits above will be stored in excel file just like MS-Excel does | |
c.PutValue(1234567890.123451711); | |
//Save the workbook | |
workbook.Save(dataDir + "out_SignificantDigits.xlsx"); |