Ange DBNum anpassad mönsterformatering
Contents
[
Hide
]
Möjliga användningsscenarier
Aspose.Cells stöderDBNumanpassad mönsterformatering. Till exempel, om ditt cellvärde är 123 och du anger dess anpassade formatering som [DBNum2][$-804]Allmänt kommer det att visas som 壹佰贰拾叁. Du kan ange din anpassade formatering av cellen medCell.GetStyle() metod ochStyle.Customfast egendom.
Exempelkod
Följande exempelkod illustrerar hur du angerDBNumanpassad mönsterformatering. Vänligen kontrollera denutgång PDF för mer hjälp.
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); | |
//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); |