[python-win32] Writing to Excel performance

Tim Roberts timr at probo.com
Fri Dec 12 19:23:51 CET 2008


Dahlstrom, Roger wrote:
> Couple of tricks I've used with some success...
>  
> 1.  If this is data only, and not formulas, you can write the data as
> an html table, but name the file something.xls - Excel will open it
> natively.
> 2.  If you need special formatting or formulas, you can write the data
> as Excel's HTML templates (make a sample file in Excel, save it as
> html, then you can see how to do it)
>  
> I believe #1 to be a security flaw in windows - that you can just name
> a file anything, and the application will open it,

No, it's not a security flaw.  The file still has to be in a format that
Excel knows how to import.  Excel just happens to understand a lot of
formats, and it reads the file to figure out what the format really is. 
It doesn't trust the extension.  Internet Explorer uses the same
tactic.  When a web page sends an attachment, it doesn't trust the MIME
type.  It reads the file to detect the file type.

If you rename an executable to xxx.xls and try to open it within it
Excel, it will complain about the format.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list