简体   繁体   English

如何使用 Aspose 单元格隐藏前缀撇号

[英]How to Hide Prefix Apostrophe using Aspose Cells

I have a text file that im converting to Excel using Aspose Cells for .NET.我有一个文本文件,可以使用 Aspose Cells for .NET 转换为 Excel。

My data contains numeric values that are being converted to scientific notation, so to counteract that I added an apostrophe to the beginning of all the the text in the file.我的数据包含正在转换为科学记数法的数值,因此为了抵消这一点,我在文件中所有文本的开头添加了一个撇号。

The file converts fine but in the final file I can still see the apostrophe when its supposed to be hidden as per Excels default behavior.该文件转换得很好,但在最终文件中,当它应该按照 Excel 的默认行为隐藏时,我仍然可以看到撇号。 I tried toggling this with the recommended code book.Settings.QuotePrefixToStyle = false;我尝试使用推荐的代码book.Settings.QuotePrefixToStyle = false;切换它book.Settings.QuotePrefixToStyle = false; but the result is the same.但结果是一样的。

Here is my code below下面是我的代码

 var book = new Aspose.Cells.Workbook(source + ".tmp.txt");
                            //book.Worksheets[0].Cells.ConvertStringToNumericValue();

                            book.Settings.QuotePrefixToStyle = false;


                            book.Save(dest,Aspose.Cells.SaveFormat.Auto);

                            book.Dispose();

You do not need to add apostrophe at the beginning of all values in the text file.您不需要在文本文件中所有值的开头添加撇号。 So, kindly use your original text file or do remove "'" with the values in the file (and re-save it).因此,请使用您的原始文本文件或使用文件中的值删除“'”(并重新保存)。 Now Please try the following sample code with your file to accomplish your task.现在请使用您的文件尝试以下示例代码以完成您的任务。 The output file will not contain scientific notation rather original values/data.输出文件将不包含科学记数法而是原始值/数据。

eg例如

Sample code:示例代码:

TxtLoadOptions options = new TxtLoadOptions();
options.ConvertNumericData = false;
Workbook book = new Workbook(source + ".tmp.txt", options);

book.Save(dest, Aspose.Cells.SaveFormat.Auto);

You may also post your queries or issue samples in Aspose.Cells forum , we can help you there.您也可以在 Aspose.Cells论坛中发布您的疑问或问题示例,我们可以在那里为您提供帮助。

PS.附注。 I am working as Support developer/ Evangelist at Aspose.我在 Aspose 担任支持开发人员/布道者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM