I have an excel File that has some formatting in it that I would like to
preserve (some cells have background color, etc). I'd like to remove a list
of email addresses from this file. My first thought is to use cffile with
action read, use the following in a cfloop: replace(emailAddressToDelete,
excelFileVarCreatedFromCffileRead) and then save it back to excel format with
cffile using action write. I tried this and the Excel file would not open.
The error was:
test.xls cannot be accessed. The file may be read-only, or you may be trying
to access a read-only location. Or, the server the document is stored on may
not be responding.
I'm guessing something went wrong in the process of reading and writing the
files contents and it's not as simple as I want to make it. Anyone have
something to tell me that might help me remove email addresses from a formatted
Excel spreadsheet?
Ian Skinner - 29 Feb 2008 19:31 GMT
> I'm guessing something went wrong in the process of reading and writing the
> files contents and it's not as simple as I want to make it. Anyone have
> something to tell me that might help me remove email addresses from a formatted
> Excel spreadsheet?
Yup, .xls is a proprietary encrypted file format and <cffile.... is not
going to be able to successfully read and modify it's content. You can
copy it or move it, but not modify it with <cffile...>
If the file format was a plain text such as .txt or .csv you could do
what you are thinking about, but then you would probably not have the
proprietary excel formating in the file.
I've heard about the POI library that allows some native Excel access
and such, but I am not knowledgeable in its ins and outs.
JR "Bob" Dobbs - 29 Feb 2008 19:44 GMT
CFFILE is primarily used for text files, take a look at Apache POI or another
Java based Excel utility.
http://poi.apache.org/hssf/index.html
http://www.bennadel.com/blog/474-ColdFusion-Component-Wrapper-For-POI-To-Read-An
d-Write-Excel-Files.htm