Cannot write to Excel (.xlxs)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Cannot write to Excel (.xlxs)

Post by dunbarx » Fri Dec 30, 2016 9:39 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Cannot write to Excel (.xlxs)

Post by FourthWorld » Fri Dec 30, 2016 9:45 pm

.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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Cannot write to Excel (.xlxs)

Post by dunbarx » Fri Dec 30, 2016 11:58 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Cannot write to Excel (.xlxs)

Post by FourthWorld » Sat Dec 31, 2016 12:15 am

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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Cannot write to Excel (.xlxs)

Post by dunbarx » Tue Jan 03, 2017 7:16 pm

Richard.

Thanks. I will work around this.

Craig

Post Reply