セルの先頭のアポストロフィを表示する
Contents
[
Hide
]
セルの先頭のアポストロフィを表示する
Microsoft Excel では、セルの値の先頭のアポストロフィが非表示になっています。 Aspose.Cells は、デフォルトでアポストロフィを表示する機能を提供します。このために、API が提供します。Workbook.Settings.QuotePrefixToStyle財産。このプロパティは、QuotePrefix単一引用符で始まる文字列値をセルに入力するときのプロパティ。の設定Workbook.Settings.QuotePrefixToStyleプロパティへ間違い出力Excelファイルに先頭のアポストロフィが表示されます。
次のスクリーンショットは、アポストロフィが表示された出力 Excel ファイルを示しています。
次のコード スニペットは、ソースの Excel ファイルにスマート マーカーを使用してデータを追加することで、これを示しています。参照用にソースと出力の Excel ファイルが添付されています。
サンプルコード
This file contains 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 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; | |
} | |
} |