Ange anpassade nummerdecimaler och gruppavgränsare för arbetsbok
Contents
[
Hide
]
I Microsoft Excel kan du ange anpassade decimaler och tusentals avgränsare istället för att använda systemavgränsare frånAvancerade Excel-alternativ som visas i skärmdumpen nedan.
Aspose.Cells tillhandahållerWorkbookSettings.NumberDecimalSeparator ochWorkbookSettings.NumberGroupSeparator egenskaper för att ställa in anpassade avgränsare för formatering/analys av tal.
Ange anpassade avgränsare med Microsoft Excel
Följande skärmdump visarAvancerade Excel-alternativ och markerar avsnittet för att angeAnpassade separatorer.
Ange anpassade avskiljare med Aspose.Cells
Följande exempelkod illustrerar hur man anger anpassade avgränsare med Aspose.Cells API. Den anger anpassade nummerdecimaler och gruppseparatorer som punkt respektive mellanslag.
C#-kod för att ange anpassade nummerdecimaler och gruppseparatorer
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); | |
Workbook workbook = new Workbook(); | |
// Specify custom separators | |
workbook.Settings.NumberDecimalSeparator = '.'; | |
workbook.Settings.NumberGroupSeparator = ' '; | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Set cell value | |
Cell cell = worksheet.Cells["A1"]; | |
cell.PutValue(123456.789); | |
// Set custom cell style | |
Style style = cell.GetStyle(); | |
style.Custom = "#,##0.000;[Red]#,##0.000"; | |
cell.SetStyle(style); | |
worksheet.AutoFitColumns(); | |
// Save workbook as pdf | |
workbook.Save(dataDir + "CustomSeparator_out.pdf"); |