Worksheet from DataTable, worksheet.SaveAs (txt or csv) does not include Time on Oracle DateTime column

We are using MicrosoftExcelUtils.CreateWorksheet(DataTable data, bool headers) to generate a worksheet from data retrieved from an Oracle database. The DateTime columns are losing the time portion when we save to .txt or .csv but are working fine when saving to .xlsx.

The DateTime used to save properly with time but stopped working recently when we migrated to AWS ECS containers. 

Is there a way we can make all DateTime include the time portion? We don't always know which column is a DateTime format, the query can be user specified.

Our code looks like:

Snippet
var excel = CreateWorksheet(data.Tables[0], headers);
var workbook = excel.Item1;
var worksheet = excel.Item2;
switch (fileType.ToLower()) {
    case "xlsx":
        workbook.SaveAs(stream);
        break;
    case "xml":
        workbook.SaveAsXml(stream, ExcelXmlSaveType.MSExcel);
        break;
    case "csv":
        worksheet.SaveAs(stream, ",", Encoding.ASCII);
        worksheet.Range
        break;
    case "txt":
        worksheet.SaveAs(stream, "\t", Encoding.ASCII);
        break;
    default:
        worksheet.SaveAs(stream, " ", Encoding.ASCII);
        break;
 }
Snippet
<package id="Syncfusion.XlsIO.AspNet" version="21.2.10" targetFramework="net48" />

p.s. Richard Bianco is posting this question under the account of Peter DeNoyelles. 


1 Reply

YV Yaavann Vignesh Sethuraman Syncfusion Team November 26, 2024 04:31 PM UTC

Hi Peter deNoyelles

We have tried saving the excel document with date time values as CSV file. We observed that when viewing the csv file in MS Excel the time portion is changed, MS Excel also behaves  in the same way. We have shared the sample tried at our end, output document and MS Excel converted document for your reference. Kindly please refer to it. If you are facing any other issues, please share the issue reproducing sample along with the input documents to validate the issue and provide you a solution at the earliest. We appreciate your patience.

Regards,
Yaavann.


Attachment: Sample_7afe2180.zip

Loader.
Up arrow icon