Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
When you put a value inside a cell that has a leading apostrophe or single‑quote mark, Microsoft Excel hides it, but when you select the cell, it displays the leading apostrophe or single quote in the formula bar, as shown in the following screenshot.

Aspose.Cells also hides the leading apostrophe or single quote like Microsoft Excel, but it sets the Style.GetQuotePrefix() property to true for that cell. If you set an empty style for the cell, then Style.GetQuotePrefix() becomes false again. To deal with this situation, Aspose.Cells provides the StyleFlag.GetQuotePrefix() property. When it is set to false, Style.GetQuotePrefix() is not updated at all and its previous value is preserved. This means that if the old value of the Style.GetQuotePrefix() property was true, it will remain true; if the old value was false, it will remain false.
The following sample code demonstrates the usage of the StyleFlag.GetQuotePrefix() property as described above. Please read the comments inside the code and see the console output for more help.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Create workbook
Workbook wb;
// Access first worksheet
Worksheet ws = wb.GetWorksheets().Get(0);
// Access cell A1
Cell cell = ws.GetCells().Get(u"A1");
// Put some text in the cell; it does not have a leading single quote
cell.PutValue(u"Text");
// Access style of cell A1
Style st = cell.GetStyle();
// Print the value of Style.QuotePrefix of cell A1
std::cout << "Quote Prefix of Cell A1: " << st.GetQuotePrefix() << std::endl;
// Put some text in the cell; it has a leading single quote
cell.PutValue(u"'Text");
// Access style of cell A1
st = cell.GetStyle();
// Print the value of Style.QuotePrefix of cell A1
std::cout << "Quote Prefix of Cell A1: " << st.GetQuotePrefix() << std::endl;
// Print information about StyleFlag.QuotePrefix property
std::cout << std::endl;
std::cout << "When StyleFlag.QuotePrefix is false, it means do not update the value of Cell.Style.QuotePrefix." << std::endl;
std::cout << "Similarly, when StyleFlag.QuotePrefix is true, it means update the value of Cell.Style.QuotePrefix." << std::endl;
std::cout << std::endl;
// Create an empty style
st = wb.CreateStyle();
// Create style flag – set StyleFlag.QuotePrefix to false
// It means we do not want to update the Style.QuotePrefix property of cell A1's style.
StyleFlag flag;
flag.SetQuotePrefix(false);
// Create a range consisting of the single cell A1
Range rng = ws.GetCells().CreateRange(u"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.
std::cout << "Quote Prefix of Cell A1: " << st.GetQuotePrefix() << std::endl;
// Create another empty style
st = wb.CreateStyle();
// Create style flag – set StyleFlag.QuotePrefix to true
// It means we want to update the Style.QuotePrefix property of cell A1's style.
flag.SetQuotePrefix(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.
std::cout << "Quote Prefix of Cell A1: " << st.GetQuotePrefix() << std::endl;
Aspose::Cells::Cleanup();
}
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: FalseAnalyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.