|
Hello Mark,
CurRow = 8;
CurCell = 6;
hssf_formula( row: CurCell: 'SUM('+StartCellCR+':'+EndCellCR+')':
Value);
Notice that you're not using CurRow anywhere , other than assigning it a value?
You're missing a line of code that does this:
row = HSSFSheet_getRow( sheet: CurRow);
Otherwise "row" will still be set to the last row you retrieved from the
first sheet. And since it's a reference to the first sheet, when you add
a new cell to it, the new cell goes on the first sheet as well.
Also, this code will fail if there's already a cell at row 8, cell 6. It might be smart to check for an existing cell first, and update it if it exists. Something like this should work:
formula = 'SUM(' + StartCellCR + ':' + EndCellCR+')';
cell = HSSFRow_getCell( row: CurCell );
if (cell = *null);
hssf_formula( row: CurCell: formula: value);
else;
formstr = new_String(formula);
HSSFCell_setCellType(cell: CELL_TYPE_FORMULA);
HSSFCell_setCellFormula(cell: formstr);
HSSFCEll_setCellStyle(cell: value);
hssf_freeLocalRef(formstr);
hssf_freeLocalRef(cell);
endif;
Actually, now that I'm thinking about it, changing hssf_formula (and the
other routines, hssf_text, hssf_num, hssf_date) to do this automatically
might be a good idea. Maybe I'll do that when I get a chance.
Good luck
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.