Показать начальный апостроф в ячейках
Contents
[
Hide
]
Показать начальный апостроф в ячейках
В Microsoft Excel начальный апостроф в значении ячейки скрыт. Aspose.Cells предоставляет возможность отображать апостроф по умолчанию. Для этого API предоставляетWorkbook.Settings.QuotePrefixToStyleимущество. Это свойство указывает, следует ли устанавливатьЦитатаПрефикссвойство при вводе строкового значения, начинающегося с одинарной кавычки в ячейку. НастройкаWorkbook.Settings.QuotePrefixToStyleсобственность наЛОЖЬотобразит начальный апостроф в выходном файле Excel.
На следующем снимке экрана показан выходной файл Excel с видимым апострофом.
Следующий фрагмент кода демонстрирует это, добавляя данные со смарт-маркерами в исходный файл Excel. Исходный и выходной файлы Excel прилагаются для ознакомления.
Образец кода
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
РеализацияОбъект данныхкласс указан ниже
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} | |
} |