Show leading apostrophe in cells

Contents
[ ]

In Microsoft Excel, the leading apostrophe in the cell’s value is hidden. Aspose.Cells provides the feature to display the apostrophe by default. For this, the API provides Workbook.Settings.QuotePrefixToStyle property. This property indicates whether to set the QuotePrefix property when entering string value starting with a single quote to the cell. Setting the Workbook.Settings.QuotePrefixToStyle property to false will display the leading apostrophe in the output excel file.

The following screenshot shows the output excel file with the visible apostrophe.

todo:image_alt_text

The following code snippet demonstrates this by adding data with Smart Markers in the source excel file. The source and output excel files are attached for reference.

Source File

Output File

Sample Code

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
string outputDir = RunExamples.Get_OutputDirectory();
// Instantiating a WorkbookDesigner object
WorkbookDesigner designer = new WorkbookDesigner();
Workbook workbook = new Workbook(sourceDir + "AllowLeadingApostropheSample.xlsx");
workbook.Settings.QuotePrefixToStyle = false;
// Open a designer spreadsheet containing smart markers
designer.Workbook = workbook;
List<DataObject> list = new List<DataObject>
{
new DataObject
{
Id =1,
Name = "demo"
},
new DataObject
{
Id=2,
Name = "'demo"
}
};
// Set the data source for the designer spreadsheet
designer.SetDataSource("sampleData", list);
// Process the smart markers
designer.Process();
designer.Workbook.Save(outputDir + "AllowLeadingApostropheSample_out.xlsx");

The implementation of DataObject class is given below

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
internal class DataObject
{
public int Id { get; set; }
public string Name { get; set; }
}