Quotes on Tab Delimited save

Good morning,

When saving a tab delimited text file, if a field has a quote within it the whole field gets quoted. I have tried encoding and the text load options. I am using the most recent dll 7.3.
Here is an example:
Data retrieved: #7-7/8"
Tab delimited txt file shows: #7-7/8” <-- quotes were inserted.

Is this a bug or am I missing setting an option to disable the insertion of quotes?

Hi,


Aspose.Cells should work fine similar to MS Excel.

Kindly attach your template and output files. Also, paste your sample code here, we will check your issue soon.

Thank you.

I have attached the tab delimited file and the excel file, to show that for the excel file it has no issue. Also the code for the creation of the files are below.


public void FillData(System.IO.Stream excelFile, string saveTo, IList objects,
bool shouldIncludeExcelFile)
{
Workbook workBook = new Workbook(excelFile);
workBook.Worksheets.ActiveSheetIndex = 0;
Worksheet workSheet = workBook.Worksheets[0];

workSheet.Cells.ImportCustomObjects(objects.ToList(), 0, 0,
new ImportTableOptions
{
TotalRows = objects.Count,
TotalColumns = -1,
IsFieldNameShown = true
});

if (shouldIncludeExcelFile)
{
Aspose.Cells.Tables.ListObject lo = workSheet
.ListObjects[workSheet.ListObjects.Add(0, 0, workSheet.Cells.MaxDataRow,
workSheet.Cells.MaxDataColumn, true)];
lo.TableStyleType = Aspose.Cells.Tables.TableStyleType.TableStyleMedium2;
workSheet.AutoFitColumns();
workBook.Save(string.Format("{0}.xlsx", saveTo), SaveFormat.Xlsx);

}
TxtSaveOptions options = new TxtSaveOptions(SaveFormat.TabDelimited) { };
// workBook.Settings.Encoding = Encoding.ASCII; //doesnt work
workBook.Save(string.Format("{0}.txt", saveTo), options);
}

Hi,


Thanks for sharing the sample files.

Well, Aspose.Cells follows MS Excel standards, it is the behavior of MS Excel to add quotes around those string values. For confirmation, you may open the Excel file into MS Excel (e.g 2007), now save it as Text (Tab Delimited). Now open the text file into Notepad and compare it with “quoteText.txt”, you will the file is same as output file generated by Aspose.Cells.

My simplest code to authenticate via Aspose.Cells APIs is given below. I compare it with MS Excel’s resaved version of the file (quoteTest.xlsx), it is identical.

Sample code:

Workbook workbook = new Workbook(“e:\test2\quoteTest.xlsx”);
//Instantiate Text File’s Save Options
TxtSaveOptions options = new TxtSaveOptions(SaveFormat.TabDelimited);
//Specify the separator
options.AlwaysQuoted = false;
//Save the file with the options
workbook.Save(“e:\test2\quoteTest.txt”, options);


Let us know if you still have any confusion.

Thank you.

Hi,

I understand that this is the default functionality of Excel but I want to not have the quotes inserted for special characters. Is there a way do to this or is this a limitation of aspose cells?

Hi,


Well, I think it is not the limitation of Aspose.Cells but rather MS Excel’s behavior. We need to investigate and look into it if we can support your needs or not. I have logged a ticket for it with an id: CELLSNET-40932. Our concerned developer will look into it and we will get back to you soon.

Thank you.

Hi,

Please download and try the lasted fix: Aspose.Cells for .NET v7.3.0.4

We have added one new option (TxtSaveOptions.QuoteType) to avoid unnecessary
quotation marks.

C#

workbook.save(“res.csv”, new TxtSaveOptions() { QuoteType = TxtValueQuoteType.Minimum });


The issues you have found earlier (filed as CELLSNET-40932) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
1 Like