Page 1 of 1

Cannot write to Excel (.xlxs)

Posted: Fri Dec 30, 2016 9:39 pm
by dunbarx
Beginners section yet again.

I have no issues writing to an excel spreadsheet saved as "xls", "csv" or "text". Never did.

But if I now try to write to the latest Excel spreadsheet format (.xlsx) the file becomes corrupted.

In other words, I make an ".xlxs" spreadsheet and save it. I can open and reopen from the finder, modify and save as needed. If I then try to write to that file:

Code: Select all

 open file filePathName for text write
   write "xyz" to file pathName
   close file filePathName
I get a dialog stating that "the file format or extension is not valid...". Again, this exact code works fine in the older Excel formats.

OSX 10.9.5. LC 6.7.9 (yes, I know...)

Craig Newman

Re: Cannot write to Excel (.xlxs)

Posted: Fri Dec 30, 2016 9:45 pm
by FourthWorld
.xlxs files are a collection of XML and other data packed into a Zip file. So unless the data being written to disk is in Zip format, no program expecting to work with a valid .xlxs file will be able to handle it.

There was a thread here a few weeks back about that format; I don't recall which section it was in, you may need to search for it.

Re: Cannot write to Excel (.xlxs)

Posted: Fri Dec 30, 2016 11:58 pm
by dunbarx
Richard.

Found a bunch of stuff, including a thread started by me about writing to an open excel file.

I will try to make an ".xls" file work in my project, and all issues will go away. I assume (hope) this file format is still supported on Window 7.

Odd though, that an ".xlsx" file looks and feels just like a simple (non-zipped) file when you see it and use it, that is, leave it lying around on the desktop, open, modify and save, just a new "version" of excel, one would think, but not when LC tries to write to it.

Craig

Re: Cannot write to Excel (.xlxs)

Posted: Sat Dec 31, 2016 12:15 am
by FourthWorld
It's a single file, but not simple. LiveCode files are a single file, and are easy to work with - because the software equipped to use them does a lot of work behind the scenes. That's pretty much true of any complex binary format.

You could use the revZip external to create them, but that's the easy part. If you look up the format of the many parts within the file at MSDN you may want to try for something simpler. To get a feel for what you'd be in for, change the file extension to .zip and open it up and poke around. Lots of parts and pieces in there, for the content, style runs, formulas, etc.

Maybe better to just export as tab-delimited and let Excel import that?

Re: Cannot write to Excel (.xlxs)

Posted: Tue Jan 03, 2017 7:16 pm
by dunbarx
Richard.

Thanks. I will work around this.

Craig