open(.xls file, 'w') so that hyperlinks appear

Peter Hansen peter at engcorp.com
Tue Nov 13 02:05:13 CET 2001


Lemniscate wrote:
> 
> To create an
> Excel file, for example, I just save to an .xls file (as opposed to
> using Dispatch from the win32all package, which I didn't know how to
> use when I started).  

>     fout = open(r"accessionnolinks.xls", 'w') # open a file to write
> to, xls makes it an excel file under windows

This doesn't "make it an Excel file", it just gives it a file
extension of .XLS.  If Excel is happy reading the file in, it's
because it knows enough to examine the file and understand that
it's actually a CSV (comma-separated) or maybe tab-separated
ASCII text file containing some kind of spreadsheet-like 
information.

Put another way, this is in no way a Python problem, and purely
an Excel one, and possibly one that has no solution.

Why not try writing out a spreadsheet which *does* have a link
in it, as both an XLS files and a CSV file?  Examine them and
figure out what Excel does to save the links.  Read the CSV
file back in (after renaming to XLS maybe) and see if the link
survives the trip.  If it does, you should be able to figure
it out from that, or go on the web and find some docs on 
Excel's file formats...

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list