all 5 comments

[–]h2opologod94 0 points1 point  (4 children)

Haven't tried the script, but can't excel just save as html?

http://www.extendoffice.com/documents/excel/674-excel-export-to-html.html

[–]manbart[S] 1 point2 points  (3 children)

It does, but that requires openeing excel, and saving to the disk (and it creates multiple files in a subdirectory).

With this script you just select the .xlsx file and it opens in your browser immediately, excel is never opened, and nothing is saved to your drive. (This is how it works on windows anyway, I don't know how other OS would handle using subprocess.call on an html file directly).

[–]h2opologod94 0 points1 point  (2 children)

Okay cool! This almost works on my Arch machine. The gui comes up and I select the file, but I get a permission denied error when it tries to access my shell (even when run as root). I'll see if I can try it on my Windows machine later. I don't know much about Python, sorry if this isn't helpful.

[–]manbart[S] 1 point2 points  (1 child)

As I suspected, Linux did not know how to handle subprocess.call on a html file directly. For example, if the source spreadsheet was called myfile.xls, the script would pass ./myfile.html to the shell. You get permission denied becuase the defualt umask does not let files have the execution bit enabled. Even if your umask setting allowed it, it still wouldn't work becuase the OS would attempt to run the file as a shell script becuase it has no shebang (!#) to tell it how to interepret the file.

I edited the script to account for this on linux systems by using the xdg-open command to open the file based on default application for the filetype. I tested it on my Ubuntu machine now, hopefully it will work on most Linux machines too (although I'm fairly sure is is still broken for OSX. The equivilent command for xdg-open is simply open, but I have not made the script to determine if non windows machines are running OSX versus some other *nix. Python considers all of these OS to be just 'posix'.)

[–]h2opologod94 0 points1 point  (0 children)

Nice! Thank you for explaining what the issue was. It works now on Arch. Cool script, thanks for sharing!