• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 84
  • Last Modified:

Read and write from existing excel file

I have an excel file that is already created and I need to read from the file  and then write back to the same file. I have several apps the write New excel files, but this one needs updated, not a new file.
1 Solution
Don ThomsonCommented:
One way is to use MS Access.  Any relational Database program should be able to do it.
cj_ervinAuthor Commented:
Sorry, I forgot to put in the description, I have to do it from ColdFusion. I have a ColdFusion application and it needs to be read and wrote from inside the application.
What version of ColdFusion? For CF9+ you can use spreadsheet functions.

You can do a lot more, but here is a simple example of reading and updating a single cell. Not tested.

workbook = SpreadSheetRead("c:\path\yourFile.xls");
SpreadsheetSetActiveSheet(workbook, "Sheet1");
// read value in row 1, column 1
value = SpreadsheetGetCellValue(workbook, 1, 1); 
WriteDump("old value="& value);
// change value in row 1, column 1
SpreadsheetSetCellValue(workbook, "This is a new Value", 1, 1);
value = SpreadsheetGetCellValue(workbook, 1, 1); 
WriteDump("new value="& value);
// save to disk. changed last parameter to TRUE to overwrite
SpreadSheetWrite(workbook, "c:\path\yourFile.xls", false); 

Open in new window

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

cj_ervinAuthor Commented:
Unfortunately my client is still on CF 8 at this current time, in the process of an upgrade, but until then I have to work with CF 8 on their side.
(Edit) CF8 doesn't have any builtin functions. The closest is to download and use the POIUtility.cfc. I haven't used it, or CF8,  in a while, but the cfc should work in CF7+.
Yes, there are samples in the standard /examples directory of the project too ;-)

One thing to note is it only supports the old binary format .xls out of the box.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now