احصل على Cell String Value with وبدون التنسيق
Contents
[
Hide
]
يوفر Aspose.Cells طريقةCell.GetStringValue () والتي يمكن استخدامها للحصول على قيمة سلسلة الخلية مع أو بدون أي تنسيق. افترض أن لديك خلية بقيمة 0.012345 وقمت بتنسيقها لعرض منزلتين عشريتين فقط. سيتم عرضه بعد ذلك على أنه 0.01 في Excel. يمكنك استرداد قيم السلسلة مثل 0.01 و 0.012345 باستخدام امتدادCell.GetStringValue () طريقة. فإنه يأخذCellValueFormatStrategyتعداد كمعامل يحتوي على القيم التالية
- CellValueFormatStrategy.CellStyle
- CellValueFormatStrategy.DisplayStyle
- CellValueFormatStrategy.None
يشرح نموذج التعليمات البرمجية التالي استخدامCell.GetStringValue ()طريقة.
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 | |
// Create workbook | |
Workbook workbook = new Workbook(); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Access cell A1 | |
Cell cell = worksheet.Cells["A1"]; | |
// Put value inside the cell | |
cell.PutValue(0.012345); | |
// Format the cell that it should display 0.01 instead of 0.012345 | |
Style style = cell.GetStyle(); | |
style.Number = 2; | |
cell.SetStyle(style); | |
// Get string value as Cell Style | |
string value = cell.GetStringValue(CellValueFormatStrategy.CellStyle); | |
Console.WriteLine(value); | |
// Get string value without any formatting | |
value = cell.GetStringValue(CellValueFormatStrategy.None); | |
Console.WriteLine(value); |