Mostra l apostrofo iniziale nelle celle
In Microsoft Excel, l’apostrofo iniziale del valore della cella è nascosto. Aspose.Cells fornisce la funzionalità di visualizzare l’apostrofo per impostazione predefinita. A tal scopo, l’API fornisce la proprietà Workbook.Settings.QuotePrefixToStyle. Questa proprietà indica se impostare la proprietà QuotePrefix quando si inserisce un valore di stringa che inizia con un singolo apostrofo nella cella. Impostando la proprietà Workbook.Settings.QuotePrefixToStyle su false visualizzerà l’apostrofo iniziale nel file Excel di output.
Lo screenshot seguente mostra il file excel di output con l’apostrofo visibile.
Il seguente snippet di codice dimostra ciò aggiungendo dati con Smart Markers nel file excel di origine. Sono allegati i file excel di origine e di output per riferimento.
Codice di 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 della classe DataObject è 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; } | |
} |