Find if the cell value starts with single quote mark with C++
Contents
[
Hide
]
Aspose.Cells now provides the Style::QuotePrefix property to find if the cell value starts with a single quote mark. Before this property, there was no way to distinguish between strings like sample and ‘sample etc.
The following sample code explains that the strings like sample and ‘sample cannot be differentiated with Cell::GetStringValue property. Therefore we must use Style::QuotePrefix property to distinguish them.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Create workbook
Workbook wb;
// Create worksheet
Worksheet sheet = wb.GetWorksheets().Get(0);
// Access cell A1 and A2
Cell a1 = sheet.GetCells().Get(u"A1");
Cell a2 = sheet.GetCells().Get(u"A2");
// Add sample in A1 and sample with quote prefix in A2
a1.PutValue(u"sample");
a2.PutValue(u"'sample");
// Print their string values, A1 and A2 both are same
std::cout << "String value of A1: " << a1.GetStringValue().ToUtf8() << std::endl;
std::cout << "String value of A2: " << a2.GetStringValue().ToUtf8() << std::endl;
// Access styles of A1 and A2
Style s1 = a1.GetStyle();
Style s2 = a2.GetStyle();
std::cout << std::endl;
// Check if A1 and A2 has a quote prefix
std::cout << "A1 has a quote prefix: " << s1.GetQuotePrefix() << std::endl;
std::cout << "A2 has a quote prefix: " << s2.GetQuotePrefix() << std::endl;
Aspose::Cells::Cleanup();
}