1
$\begingroup$

I'm trying to import a spreadsheet with dates and export it again. But the cell reads ### in the exported file. It's shown in the screenshots. This is my code.

SetDirectory[NotebookDirectory[]];
file = Import["import.xlsx"];
Export["export.xlsx", file];

Is there some way to get this working? I'd like the export file being the same as the import file.

I was trying this with Mathematica 12 on Linux and Mathematica 11 on Windows.

Here's the import file.

http://s000.tinyupload.com/index.php?file_id=34471371704061438491

Thanks a lot!

enter image description here enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ probably has to do with the dateformat that is set up in Excel/Libreoffice. As you can see in the cell content, the date is correctly exported from Wolfram. $\endgroup$
    – FredrikD
    Nov 19, 2019 at 7:35

1 Answer 1

2
$\begingroup$

Assuming that the file is a list of dates and that the issue isn't a formatting of the cell in Libreoffice then you could do this:

file = Import[NotebookDirectory[] <> "importdate.xlsx"]; 
fileII = DateString[#, "ISODate"] & /@ Flatten[file]; 
Export[NotebookDirectory[] <> "export.xlsx", fileII]

DateString will format the date as an ISO date

$\endgroup$
2
  • $\begingroup$ Thanks, that works! I still wonder if it's possible to export the DateObject as such in the excel format but that's more curiosity. (By the way, I tried with both, LibreOffice and MS Office - it's the same) $\endgroup$
    – tukan
    Nov 19, 2019 at 17:15
  • 1
    $\begingroup$ Note that ISODate was introduced in Mathematica version 12. $\endgroup$ Mar 14, 2023 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.