セル内の先頭のアポストロフィの表示
Microsoft Excel では、セルの値の先頭にあるアポストロフィは非表示になります。Aspose.Cells では、デフォルトでアポストロフィを表示する機能が提供されます。これには、API が Workbook.Settings.QuotePrefixToStyle プロパティを提供しています。このプロパティは、シングルクオートで始まる文字列値をセルに入力する際に、QuotePrefix プロパティを設定するかどうかを示します。Workbook.Settings.QuotePrefixToStyle プロパティを false に設定すると、出力Excelファイルに先頭のアポストロフィが表示されます。
次のスクリーンショットは、先頭のアポストロフィが表示される出力Excelファイルを示しています。
このコードスニペットでは、ソースExcelファイルにSmart Markersでデータを追加しています。ソースファイルと出力ファイルは参照のために添付されています。
サンプルコード
// 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"); |
DataObject クラスの実装は以下のとおりです
// 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; } | |
} |