Mostra l'apostrofo iniziale nelle celle
In Microsoft Excel, l’apostrofo iniziale nel valore della cella è nascosto. Aspose.Cells fornisce la funzione per visualizzare l’apostrofo per impostazione predefinita. Per questo, lo API fornisceWorkbook.Settings.QuotePrefixToStyle proprietà. Questa proprietà indica se impostare ilCitazionePrefissoproprietà quando si immette un valore stringa che inizia con un singolo apice nella cella. Impostazione delWorkbook.Settings.QuotePrefixToStyle proprietà afalsovisualizzerà l’apostrofo iniziale nel file excel di output.
Lo screenshot seguente mostra il file excel di output con l’apostrofo visibile.
Il seguente frammento di codice lo dimostra aggiungendo i dati con i marcatori intelligenti nel file Excel di origine. I file excel di origine e di output sono allegati per riferimento.
Codice d’esempio
// 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"); |
L’implementazione diOggetto datila classe è riportata di seguito
// 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; } | |
} |