Specificare la formattazione del modello personalizzato DBNum
Possibili Scenari di Utilizzo
Aspose.Cells supporta la formattazione del modello personalizzato DBNum. Ad esempio, se il valore della cella è 123 e si specifica la sua formattazione personalizzata come [DBNum2][$-804]Generale, verrà visualizzato come 壹佰贰拾叁. È possibile specificare la formattazione personalizzata della cella utilizzando il metodo Cell.GetStyle() e la proprietà Style.Custom.
Codice di Esempio
Il seguente codice di esempio illustra come specificare la formattazione del modello personalizzato DBNum. Si prega di controllare il PDF di output per ulteriori informazioni.
// 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); | |
//Create a workbook. | |
Workbook wb = new Workbook(); | |
//Access first worksheet. | |
Worksheet ws = wb.Worksheets[0]; | |
//Access cell A1 and put value 123. | |
Cell cell = ws.Cells["A1"]; | |
cell.PutValue(123); | |
//Access cell style. | |
Style st = cell.GetStyle(); | |
//Specifying DBNum custom pattern formatting. | |
st.Custom = "[DBNum2][$-804]General"; | |
//Set the cell style. | |
cell.SetStyle(st); | |
//Set the first column width. | |
ws.Cells.SetColumnWidth(0, 30); | |
//Save the workbook in output pdf format. | |
wb.Save(dataDir + "outputDBNumCustomFormatting.pdf", SaveFormat.Pdf); |