From: Francogrex on
Lisp in windows:
(with-open-file (stream "c:/test.doc" :direction :output)
(format stream "Only testing word doc generation"))

ok the test.doc generated is only a plain text and not a real MS-WORD
doc.
also:
(with-open-file (stream "c:/test.xls" :direction :output)
(format stream "Only testing MS-Excel generation"))
ok the test.xls is only a plain text and not a real Excel document
(despite the extension)

Anyone knows a way to make CL (any implementation) generate native MS
documents? Or is this not related to CL or any of its implementations
but to some obscure mechanism of the OS?
(I know that the answers to such questions are unlikely because most
users are linux, but...)
From: Zach Beane on
Francogrex <franco(a)grex.org> writes:

> Lisp in windows:
> (with-open-file (stream "c:/test.doc" :direction :output)
> (format stream "Only testing word doc generation"))
>
> ok the test.doc generated is only a plain text and not a real MS-WORD
> doc.
> also:
> (with-open-file (stream "c:/test.xls" :direction :output)
> (format stream "Only testing MS-Excel generation"))
> ok the test.xls is only a plain text and not a real Excel document
> (despite the extension)
>
> Anyone knows a way to make CL (any implementation) generate native MS
> documents? Or is this not related to CL or any of its implementations
> but to some obscure mechanism of the OS?
> (I know that the answers to such questions are unlikely because most
> users are linux, but...)

One possible approach:

- learn the binary file format required to represent a valid Word or
Excel document

- open a binary stream with CL and write out the required format

That is the approach I use to write PNG and GIF files with CL.

Zach
From: fortunatus on
In general programming languages do not put anything in a file but the
bytes you write out. (Most do have "text" versus "binary", where in
text there is a small amount of character mapping. However the goal
remains to only put in the "characters" (instead of bytes) that you
write out.)

A "document" file, like you mention, is a highly structured data
file. Normally if you want to write a specially structured file, it
takes a library to generate the correct byte stream for the format.
So you can find (or buy, or write) libraries to generate various file
formats.

(If you can't find a CL-* library for the format you want, you might
look for a C library and implement a FFI definition for it, which
everyone would appreciate!! Maybe one place to look for code would be
in projects like Abiword or OpenOffice.)
From: David Thole on
Another approach as well is, at least for the XLS format, do it as CSV.

You can name the CSV still .XLS, but word will open it as a CSV.

As far as word itself, a much more simple option is to encode into into
RTF format, whic is the old word format from 10 or whatever years ago.
I'm not aware of any RTF encoders for CL, but if there aren't, it
shouldn't be too difficult for you to develop a simple one that handles
at least some cases.

-David
http://www.thedarktrumpet.com
From: Dmitry Kalyanov on
On 29 янв, 20:08, Francogrex <fra...(a)grex.org> wrote:
> Anyone knows a way to make CL (any implementation) generate native MS
> documents? Or is this not related to CL or any of its implementations
> but to some obscure mechanism of the OS?
> (I know that the answers to such questions are unlikely because most
> users are linux, but...)

You may use Windows' COM to interop with ms-word, or UNO to interop
with openoffice.

Or better, use the OpenDocument format which is quite easy to generate.