Mostra l'apostrofo iniziale nelle celle
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.QuotePrefixToStyleproprietà. Questa proprietà indica se impostare ilCitazionePrefissoproprietà quando si immette un valore stringa che inizia con un singolo apice nella cella. Impostazione delWorkbook.Settings.QuotePrefixToStyleproprietà 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-Java | |
//directories | |
String sourceDir = Utils.Get_SourceDirectory(); | |
String outputDir = Utils.Get_OutputDirectory(); | |
// Instantiating a WorkbookDesigner object | |
WorkbookDesigner designer = new WorkbookDesigner(); | |
Workbook workbook = new Workbook(sourceDir + "AllowLeadingApostropheSample.xlsx"); | |
workbook.getSettings().setQuotePrefixToStyle(false); | |
// Open a designer spreadsheet containing smart markers | |
designer.setWorkbook(workbook); | |
ArrayList<DataObject> list = new ArrayList<>(); | |
list.add(new DataObject(1, "demo")); | |
list.add(new DataObject(2, "'demo")); | |
// Set the data source for the designer spreadsheet | |
designer.setDataSource("sampleData", list); | |
// Process the smart markers | |
designer.process(); | |
designer.getWorkbook().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-Java | |
public class DataObject | |
{ | |
private int id; | |
private String name; | |
public DataObject(int id, String name) | |
{ | |
this.id = id; | |
this.name = name; | |
} | |
public int getId() | |
{ | |
return this.id; | |
} | |
public void setId(int value) | |
{ | |
this.id = value; | |
} | |
public String getName() | |
{ | |
return this.name; | |
} | |
public void setName(String value) | |
{ | |
this.name = value; | |
} | |
} |