When you create a text file using the CreateTextFile function of the
folderitem class, the file type and creator information is ignored.
This can
be a problem when you want to create a text file that when
double-clicked
will open a specific application (like Excel for example). The solution
is
to create a binary file rather than a text file.
In the example below, a binarystream is used rather than a
textoutputstream
and a binary file is created using CreateBinaryFile rather than
CreateTextFile. Since the file created is an Excel text file, columns
are
separated with a tab and rows with a carriage return. As you can see
from
the example, you can even include formulas.
dim f as FolderItem
dim output as BinaryStream
f= GetSaveFolderItem("application/vnd.ms-excel", "test.xls")
if f <> nil then
output = f.CreateBinaryFile("application/vnd.ms-excel")
output.write "5" + chr(9) + "10" + chr(13)
output.write "=a1+b1"
output.close
end if
--
Geoff Perlman
President and CEO
REAL Software, Inc.
512-328-7325 x711 (voice)
512-328-7372 (fax)
- - - - - - - - - -
Got a useful tip to share? Send it to us at:
REALbasic-tips at lists dot realsoftware dot com dot
To unsubscribe from the Tips list, send an email to
<mailto:realbasic-tips-off at lists dot realsoftware dot com>
|