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
    $\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 '19 at 7:35
1
$\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$
  • $\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 '19 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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