احتفظ ببادئة اقتباس فردية بقيمة Cell أو نطاق
سيناريوهات الاستخدام الممكنة
عندما تضع بعض القيمة داخل الخلية التي تحتوي على فاصلة عليا أو علامة اقتباس مفردة ، فإن Microsoft يقوم Excel بإخفائها ، ولكن عند تحديد الخلية ، فإنها تعرض الفاصلة العليا أو علامة الاقتباس الفردية في شريط الصيغة كما هو موضح في لقطة الشاشة التالية.
يخفي Aspose.Cells أيضًا الفاصلة العليا أو الاقتباس الفردي مثل Microsoft Excel ولكنه يحددالنمط مثلحقيقي لتلك الخلية. إذا قمت بتعيين نمط فارغ للخلية ، فحينئذٍالنمط يصبحخاطئة تكرارا. من أجل التعامل مع هذه المشكلة ، يوفر Aspose.CellsStyleFlag.QuotePrefix الملكية ، عندما يتم تعيينهاخاطئة ، ومن بعدالنمطلم يتم تحديثه على الإطلاق ويتم الاحتفاظ بقيمته القديمة. هذا يعني إذا كانت القيمة القديمةالنمطكانت الممتلكاتحقيقي ، ستبقىحقيقي وإذا كانت القيمة القديمةخاطئة ، ستبقىخاطئة.
احتفظ ببادئة اقتباس فردية بقيمة Cell أو نطاق
يشرح نموذج التعليمات البرمجية التالي استخدامStyleFlag.QuotePrefixالخاصية كما هو موضح سابقًا. يرجى قراءة التعليقات الموجودة داخل الكود والاطلاع على إخراج وحدة التحكم للرمز الوارد أدناه للحصول على مزيد من المساعدة.
عينة من الرموز
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Create workbook | |
Workbook wb = new Workbook(); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Access cell A1 | |
Cell cell = ws.Cells["A1"]; | |
//Put some text in cell, it does not have Single Quote at the beginning | |
cell.PutValue("Text"); | |
//Access style of cell A1 | |
Style st = cell.GetStyle(); | |
//Print the value of Style.QuotePrefix of cell A1 | |
Console.WriteLine("Quote Prefix of Cell A1: " + st.QuotePrefix); | |
//Put some text in cell, it has Single Quote at the beginning | |
cell.PutValue("'Text"); | |
//Access style of cell A1 | |
st = cell.GetStyle(); | |
//Print the value of Style.QuotePrefix of cell A1 | |
Console.WriteLine("Quote Prefix of Cell A1: " + st.QuotePrefix); | |
//Print information about StyleFlag.QuotePrefix property | |
Console.WriteLine(); | |
Console.WriteLine("When StyleFlag.QuotePrefix is False, it means, do not update the value of Cell.Style.QuotePrefix."); | |
Console.WriteLine("Similarly, when StyleFlag.QuotePrefix is True, it means, update the value of Cell.Style.QuotePrefix."); | |
Console.WriteLine(); | |
//Create an empty style | |
st = wb.CreateStyle(); | |
//Create style flag - set StyleFlag.QuotePrefix as false | |
//It means, we do not want to update the Style.QuotePrefix property of cell A1's style. | |
StyleFlag flag = new StyleFlag(); | |
flag.QuotePrefix = false; | |
//Create a range consisting of single cell A1 | |
Range rng = ws.Cells.CreateRange("A1"); | |
//Apply the style to the range | |
rng.ApplyStyle(st, flag); | |
//Access the style of cell A1 | |
st = cell.GetStyle(); | |
//Print the value of Style.QuotePrefix of cell A1 | |
//It will print True, because we have not updated the Style.QuotePrefix property of cell A1's style. | |
Console.WriteLine("Quote Prefix of Cell A1: " + st.QuotePrefix); | |
//Create an empty style | |
st = wb.CreateStyle(); | |
//Create style flag - set StyleFlag.QuotePrefix as true | |
//It means, we want to update the Style.QuotePrefix property of cell A1's style. | |
flag = new StyleFlag(); | |
flag.QuotePrefix = true; | |
//Apply the style to the range | |
rng.ApplyStyle(st, flag); | |
//Access the style of cell A1 | |
st = cell.GetStyle(); | |
//Print the value of Style.QuotePrefix of cell A1 | |
//It will print False, because we have updated the Style.QuotePrefix property of cell A1's style. | |
Console.WriteLine("Quote Prefix of Cell A1: " + st.QuotePrefix); |
إخراج وحدة التحكم
Quote Prefix of Cell A1: False
Quote Prefix of Cell A1: True
When StyleFlag.QuotePrefix is False, it means, do not update the value of Cell.Style.QuotePrefix.
Similarly, when StyleFlag.QuotePrefix is True, it means, update the value of Cell.Style.QuotePrefix.
Quote Prefix of Cell A1: True
Quote Prefix of Cell A1: False