From: <prn...@us...> - 2010-08-03 21:27:42
|
Revision: 7494 http://octave.svn.sourceforge.net/octave/?rev=7494&view=rev Author: prnienhuis Date: 2010-08-03 21:27:35 +0000 (Tue, 03 Aug 2010) Log Message: ----------- Support for reading back formulas as literal text strings. This works only for POI, JXL (.xls) and OTK (.ods) interfaces. Neither COM nor JOD support this :-) Also some more code cleanup Modified Paths: -------------- trunk/octave-forge/main/io/inst/ods2oct.m trunk/octave-forge/main/io/inst/xls2oct.m Modified: trunk/octave-forge/main/io/inst/ods2oct.m =================================================================== --- trunk/octave-forge/main/io/inst/ods2oct.m 2010-08-03 21:24:56 UTC (rev 7493) +++ trunk/octave-forge/main/io/inst/ods2oct.m 2010-08-03 21:27:35 UTC (rev 7494) @@ -18,6 +18,7 @@ ## @deftypefn {Function File} [ @var{rawarr}, @var{ods}, @var{rstatus} ] = ods2oct (@var{ods}) ## @deftypefnx {Function File} [ @var{rawarr}, @var{ods}, @var{rstatus} ] = ods2oct (@var{ods}, @var{wsh}) ## @deftypefnx {Function File} [ @var{rawarr}, @var{ods}, @var{rstatus} ] = ods2oct (@var{ods}, @var{wsh}, @var{range}) +## @deftypefnx {Function File} [ @var{rawarr}, @var{ods}, @var{rstatus} ] = ods2oct (@var{ods}, @var{wsh}, @var{range}, @var{options}) ## ## Read data contained within range @var{range} from worksheet @var{wsh} ## in an OpenOffice.org spreadsheet file pointed to in struct @var{ods}. @@ -37,6 +38,13 @@ ## If no range is specified the occupied cell range will have to be ## determined behind the scenes first; this can take some time. ## +## Optional argument @var{options}, a structure, can be used to +## specify various read modes. Currently the only option field is +## "formulas_as_text"; if set to TRUE or 1, spreadsheet formulas +## (if at all present) are read as formula strings rather than the +## evaluated formula result values. This only works for the OTK (Open +## Document Toolkit) interface. +## ## If only the first argument is specified, ods2oct will try to read ## all contents from the first = leftmost (or the only) worksheet (as ## if a range of @'' (empty string) was specified). @@ -97,15 +105,22 @@ ## So I added a warning for users using odfdom 0.8. ## 2010-04-11 Removed support for odfdom-0.8 - it's painfully slow and unreliable ## 2010-05-31 Updated help text (delay i.c.o. empty range due to getusedrange call) -## 2010-05-31 Added support for jOpenDocument 1.2b3; improved this subfunc a lot +## 2010-08-03 Added support for reading back formulas (works only in OTK) ## -## (Latest update of subfunctions below: 2010-05-31) +## (Latest update of subfunctions below: 2010-08-03) -function [ rawarr, ods, rstatus ] = ods2oct (ods, wsh=1, datrange=[]) +function [ rawarr, ods, rstatus ] = ods2oct (ods, wsh=1, datrange=[], spsh_opts=[]) + persistent odf08; + + if isempty (spsh_opts) + spsh_opts.formulas_as_text = 0; + # Other options here + endif + if (strcmp (ods.xtype, 'OTK')) # Read ods file tru Java & ODF toolkit - [rawarr, ods, rstatus] = ods2jotk2oct (ods, wsh, datrange); + [rawarr, ods, rstatus] = ods2jotk2oct (ods, wsh, datrange, spsh_opts); elseif (strcmp (ods.xtype, 'JOD')) [rawarr, ods, rstatus] = ods2jod2oct (ods, wsh, datrange); @@ -151,8 +166,9 @@ ## "" Tamed down memory usage for rawarr when desired data range is given ## "" Added call to getusedrange() for cases when no range was specified ## 2010-03-19 More code cleanup & fixes for bugs introduced 18/3/2010 8-() +## 2010-08-03 Added preliminary support for reading back formulas as text strings -function [ rawarr, ods, rstatus ] = ods2jotk2oct (ods, wsh=1, crange = []) +function [ rawarr, ods, rstatus ] = ods2jotk2oct (ods, wsh, crange, spsh_opts) # Parts after user gfterry in # http://www.oooforum.org/forum/viewtopic.phtml?t=69060 @@ -248,8 +264,22 @@ jj = lcol; while (jj <= rcol) tcell = row.getCellAt(jj-1); + form = 0; if (~isempty (tcell)) # If empty it's possibly in columns-repeated/spanned - if ~(index (char(tcell), 'text:p>Err:') || index (char(tcell), 'text:p>#DIV')) + if (spsh_opts.formulas_as_text) # Get spreadsheet formula rather than value + # Check for formula attribute + tmp = tcell.getTableFormulaAttribute (); + if isempty (tmp) + form = 0; + else + if (strcmp (tolower (tmp(1:3)), 'of:')) + tmp (1:end-3) = tmp(4:end); + endif + rawarr(ii-trow+2, jj-lcol+1) = tmp; + form = 1; + endif + endif + if ~(form || index (char(tcell), 'text:p>Err:') || index (char(tcell), 'text:p>#DIV')) # Get data from cell ctype = tcell.getOfficeValueTypeAttribute (); cvalue = tcell.getOfficeValueAttribute (); @@ -356,79 +386,25 @@ ## along with Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. -## ods2jod2oct - get data out of an ODS spreadsheet into octave using -## jOpenDocument. +## ods2oct - get data out of an ODS spreadsheet into octave. +## Watch out, no error checks, and spreadsheet formula error results +## are conveyed as 0 (zero). ## ## Author: Philip Nienhuis ## Created: 2009-12-13 -## Updates: -## 2010-05-31 First working updates for jopendocument v 1.2b3 -## Added getusedrange, lifted requirement of range argument -function [ rawarr, ods, rstatus] = ods2jod2oct (ods, wsh, crange=[]) +function [ rawarr, ods, rstatus] = ods2jod2oct (ods, wsh, crange) - persistent months; persistent ctype; + persistent months; months = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}; - ctype = {'FLOAT', 'STRING', 'BOOLEAN', 'DATE', 'TIME', 'EMPTY', 'CURRENCY', 'PERCENTAGE', '', ''}; - rstatus = 1 + if (isempty (crange)) error ("Empty cell range not allowed w. jOpenDocument."); endif - if (isnumeric (wsh)) - try - sh = ods.workbook.getSheet (wsh - 1); - iwsh = wsh; - catch - rstatus = 0; - error ("Sheet nr. %d out of range - only %d sheets present in file %s\n", \ - wsh, ods.workbook.getSheetCount (), ods.filename); - end_try_catch - else - sh = ods.workbook.getSheet (wsh); - if (isempty (sh)) - rstatus = 0; - error ("Sheet %s not present in file %s\n", wsh, ods.filename); - endif - if (isempty (crange)) - # In that case we need the sheet index for a call to getusedrange () - ii = 0; shcnt = ods.workbook.getSheetCount (); - while (ii < shcnt) - shname = char (ods.workbook.getSheet (ii).getName ()); - if (strcmp (shname, wsh)) - iwsh = ii + 1; - ii = shcnt; - else - ++ii; - endif - endwhile - endif - endif - - # Check jOpenDocument version - cl = sh.getCellAt (0, 0); - try - # 1.2b3 has public getValueType () - cl.getValueType () - ver = 3 - catch - # 1.2b2 has not - ver = 2 - end_try_catch - - if (isempty (crange)) - [toprow, brow, lcol, rcol] = getusedrange (ods, iwsh); - if (toprow == 0) - # Empty sheet - nrows = 0; - else - ncols = rcol - lcol + 1; - nrows = brow - toprow + 1; - endif - else - [dummy, nrows, ncols, toprow, lcol] = parse_sp_range (crange); - if (lcol > 1024 || toprow > 65536) error ("ods2oct: invalid range; max 1024 columns & 65536 rows."); endif - brow = toprow + nrows - 1; - rcol = lcol + ncols - 1; - endif + if (isnumeric(wsh)) wsh = max (wsh - 1, 1); endif # Sheet COUNT starts at 0! + sh = ods.workbook.getSheet (wsh); + + [dummy, nrows, ncols, toprow, lcol] = parse_sp_range (crange); + if (lcol > 1024 || toprow > 65536) error ("ods2oct: invalid range; max 1024 columns & 65536 rows."); endif # Truncate range silently if needed rcol = min (lcol + ncols - 1, 1024); ncols = min (ncols, 1024 - lcol + 1); @@ -436,123 +412,48 @@ # Placeholder for data rawarr = cell (nrows, ncols); - - # Get data from sheet - if (ver ==3) # jOpenDocument version 1.2b3 - - for ii=1:nrows - for jj = 1:ncols - cl = sh.getCellAt (jj+lcol-2, ii+toprow-2); - valtype = char (cl.getValueType ()); - if (~isempty (valtype)) - switch deblank (valtype) - case {'FLOAT', 'CURRENCY', 'PERCENTAGE'} - # Check for error values - txt = cl.getTextValue (); - if ~(strfind (txt, 'Err:') || strfind (txt, '#DIV/0')) - rawarr (ii, jj) = cl.getValue ().doubleValue (); - endif - case 'STRING' - rawarr (ii, jj) = cl.getTextValue (); - case 'BOOLEAN' - rawarr (ii, jj) = cl.getValue (); - case 'DATE' - cl = char (cl); - st = strfind (cl, 'office:date-value=') + 19; - en = strfind (cl(st:end), '">')(1) + st - 2; - cvalue = cl(st:en); - # Dates are returned as octave datenums, i.e. 0-0-0000 based - yr = str2num (cvalue(1:4)); - mo = str2num (cvalue(6:7)); - dy = str2num (cvalue(9:10)); - if (index (cvalue, 'T')) - hh = str2num (cvalue(12:13)); - mm = str2num (cvalue(15:16)); - ss = str2num (cvalue(18:19)); - rawarr(ii, jj) = datenum (yr, mo, dy, hh, mm, ss); - else - rawarr(ii, jj) = datenum (yr, mo, dy); - endif - case 'TIME' - cl = char (cl); - st = strfind (cl, 'office:time-value=') + 19; - en = strfind (cl(st:end), '">')(1) + st - 2; - cvalue = cl(st:en); - if (index (cvalue, 'PT')) - hh = str2num (cvalue(3:4)); - mm = str2num (cvalue(6:7)); - ss = str2num (cvalue(9:10)); - rawarr(ii, jj) = datenum (0, 0, 0, hh, mm, ss); - endif - otherwise - endswitch - endif - endfor - endfor - - elseif (ver ==2 ) # jOpenDocument version 1.2b2 - - for ii=1:nrows - for jj = 1:ncols - celladdress = calccelladdress (toprow, lcol, ii, jj); - try - val = sh.getCellAt (celladdress).getValue (); - catch - # No panic, probably a merged cell - val = {}; - end_try_catch - if (~isempty (val)) - if (ischar (val)) - # Text string + for ii=1:nrows + for jj = 1:ncols + celladdress = calccelladdress (toprow, lcol, ii, jj); + try + val = sh.getCellAt (celladdress).getValue (); + catch + # No panic, probably a merged cell + val = {}; + end_try_catch + if (~isempty (val)) + if (ischar (val)) + # Text string + rawarr(ii, jj) = val; + elseif (isnumeric (val)) + # Boolean + if (val) rawarr(ii, jj) = true; else; rawarr(ii, jj) = false; endif + else + try + val = sh.getCellAt (celladdress).getValue ().doubleValue (); rawarr(ii, jj) = val; - elseif (isnumeric (val)) - # Boolean - if (val) rawarr(ii, jj) = true; else; rawarr(ii, jj) = false; endif - else - try - val = sh.getCellAt (celladdress).getValue ().doubleValue (); - rawarr(ii, jj) = val; - catch - val = char (val); - if (isempty (val)) - # Probably empty Cell - else - # Maybe date / time value. Dirty hack to get values: - mo = strmatch (toupper (val(5:7)), months); - dd = str2num (val(9:10)); - yy = str2num (val(25:end)); - hh = str2num (val(12:13)); - mm = str2num (val(15:16)); - ss = str2num (val(18:19)); - rawarr(ii, jj) = datenum (yy, mo, dd, hh, mm,ss); - endif - end_try_catch - endif + catch + val = char (val); + if (isempty (val)) + # Probably empty Cell + else + # Maybe date / time value. Dirty hack to get values: + mo = strmatch (toupper (val(5:7)), months); + dd = str2num (val(9:10)); + yy = str2num (val(25:end)); + hh = str2num (val(12:13)); + mm = str2num (val(15:16)); + ss = str2num (val(18:19)); + rawarr(ii, jj) = datenum (yy, mo, dd, hh, mm,ss); + endif + end_try_catch endif - endfor + endif endfor + endfor + + ods.limits = [ lcol, lcol+ncols-1; toprow, toprow+nrows-1 ]; + + rstatus = ~isempty (rawarr); - endif - - # Crop rawarr from all empty outer rows & columns just like Excel does - # & keep track of limits - emptr = cellfun('isempty', rawarr); - if (all (all (emptr))) - rawarr = {}; - ods.limits= []; - else - irowt = 1; - while (all (emptr(irowt, :))), irowt++; endwhile - irowb = nrows; - while (all (emptr(irowb, :))), irowb--; endwhile - icoll = 1; - while (all (emptr(:, icoll))), icoll++; endwhile - icolr = ncols; - while (all (emptr(:, icolr))), icolr--; endwhile - # Crop textarray - rawarr = rawarr(irowt:irowb, icoll:icolr); - rstatus = 1; - ods.limits = [lcol+icoll-1, lcol+icolr-1; toprow+irowt-1, toprow+irowb-1]; - endif - endfunction Modified: trunk/octave-forge/main/io/inst/xls2oct.m =================================================================== --- trunk/octave-forge/main/io/inst/xls2oct.m 2010-08-03 21:24:56 UTC (rev 7493) +++ trunk/octave-forge/main/io/inst/xls2oct.m 2010-08-03 21:27:35 UTC (rev 7494) @@ -18,6 +18,7 @@ ## @deftypefn {Function File} [ @var{rawarr}, @var{xls}, @var{rstatus} ] = xls2oct (@var{xls}) ## @deftypefnx {Function File} [ @var{rawarr}, @var{xls}, @var{rstatus} ] = xls2oct (@var{xls}, @var{wsh}) ## @deftypefnx {Function File} [ @var{rawarr}, @var{xls}, @var{rstatus} ] = xls2oct (@var{xls}, @var{wsh}, @var{range}) +## @deftypefnx {Function File} [ @var{rawarr}, @var{xls}, @var{rstatus} ] = xls2oct (@var{xls}, @var{wsh}, @var{range}, @var{options}) ## ## Read data contained within range @var{range} from worksheet @var{wsh} ## in an Excel spreadsheet file pointed to in struct @var{xls}. @@ -35,6 +36,13 @@ ## determined behind the scenes first; this can take some time for the ## Java-based interfaces. ## +## Optional argument @var{options}, a structure, can be used to +## specify various read modes. Currently the only option field is +## "formulas_as_text"; if set to TRUE or 1, spreadsheet formulas +## (if at all present) are read as formula strings rather than the +## evaluated formula result values. This only works for the Java +## based interfaces (POI and JXL). +## ## If only the first argument is specified, xls2oct will try to read ## all contents from the first = leftmost (or the only) worksheet (as ## if a range of @'' (empty string) was specified). @@ -99,18 +107,24 @@ ## ADDRESS function still not working OK) ## 2010-03-14 Updated help text ## 2010-05-31 Updated help text (delay i.c.o. empty range due to getusedrange call) +## 2010-07-28 Added option to read formulas as text strings rather than evaluated value -function [ rawarr, xls, rstatus ] = xls2oct (xls, wsh, datrange='') +function [ rawarr, xls, rstatus ] = xls2oct (xls, wsh, datrange='', spsh_opts=[]) + if isempty (spsh_opts) + spsh_opts.formulas_as_text = 0; + # Other future options here + endif + if (strcmp (xls.xtype, 'COM')) # Call Excel tru COM server [rawarr, xls, rstatus] = xls2com2oct (xls, wsh, datrange); elseif (strcmp (xls.xtype, 'POI')) # Read xls file tru Java POI - [rawarr, xls, rstatus] = xls2jpoi2oct (xls, wsh, datrange); + [rawarr, xls, rstatus] = xls2jpoi2oct (xls, wsh, datrange, spsh_opts); elseif (strcmp (xls.xtype, 'JXL')) # Read xls file tru JExcelAPI - [rawarr, xls, rstatus] = xls2jxla2oct (xls, wsh, datrange); + [rawarr, xls, rstatus] = xls2jxla2oct (xls, wsh, datrange, spsh_opts); # elseif ---- <Other interfaces here> @@ -123,7 +137,7 @@ #==================================================================================== -## Copyright (C)2009 P.R. Nienhuis, <pr.nienhuis at hccnet.nl> +## Copyright (C) 2009 P.R. Nienhuis, <pr.nienhuis at hccnet.nl> ## ## based on mat2xls by Michael Goffioul (2007) <mic...@sw...> ## @@ -293,12 +307,14 @@ ## Updates: ## 2010-01-11 Fall back to cached values when formula evaluator fails ## 2010-03-14 Fixed max column nr for OOXML for empty given range +## 2010-07-28 Added option to read formulas as text strings rather than evaluated value +## 2010-08-01 Some bug fixes for formula reading (cvalue rather than scell) -function [ rawarr, xls, status ] = xls2jpoi2oct (xls, wsh, cellrange=[]) +function [ rawarr, xls, status ] = xls2jpoi2oct (xls, wsh, cellrange=[], spsh_opts) persistent ctype; if (isempty (ctype)) - # Get enumrated cell types. Beware as they start at 0 not 1 + # Get enumerated cell types. Beware as they start at 0 not 1 ctype(1) = java_get ('org.apache.poi.ss.usermodel.Cell', 'CELL_TYPE_NUMERIC'); ctype(2) = java_get ('org.apache.poi.ss.usermodel.Cell', 'CELL_TYPE_STRING'); ctype(3) = java_get ('org.apache.poi.ss.usermodel.Cell', 'CELL_TYPE_FORMULA'); @@ -337,6 +353,7 @@ lastrow = sh.getLastRowNum (); if (isempty (cellrange)) # Get used range by searching (slow...). Beware, it can be bit unreliable + ## FIXME - can be replaced by call to getusedrange.m # lcol = 65535; # Old xls value lcol = 1048576; # OOXML (xlsx) max. rcol = 0; @@ -375,43 +392,50 @@ scol = (irow.getFirstCellNum).intValue (); ecol = (irow.getLastCellNum).intValue () - 1; for jj = max (scol, lcol) : min (lcol+ncols-1, ecol) - cell = irow.getCell (jj); - if ~isempty (cell) + scell = irow.getCell (jj); + if ~isempty (scell) # Explore cell contents - type_of_cell = cell.getCellType (); + type_of_cell = scell.getCellType (); if (type_of_cell == ctype(3)) # Formula - try # Because not al Excel formulas have been implemented - cell = frm_eval.evaluate (cell); - type_of_cell = cell.getCellType(); - # Separate switch because form.eval. yields different type - switch type_of_cell - case ctype (1) # Numeric - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getNumberValue (); - case ctype(2) # String - rawarr (ii+1-firstrow, jj+1-lcol) = char (cell.getStringValue ()); - case ctype (5) # Boolean - rawarr (ii+1-firstrow, jj+1-lcol) = cell.BooleanValue (); - otherwise - # Nothing to do here - endswitch - # Set cell type to blank to skip switch below - type_of_cell = ctype(4); - catch - # In case of formula errors we take the cached results - type_of_cell = cell.getCachedFormulaResultType (); - ++jerror; # We only need one warning even for multiple errors - end_try_catch + if ~(spsh_opts.formulas_as_text) + try # Because not al Excel formulas have been implemented + cvalue = frm_eval.evaluate (scell); + type_of_cell = cvalue.getCellType(); + # Separate switch because form.eval. yields different type + switch type_of_cell + case ctype (1) # Numeric + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getNumberValue (); + case ctype(2) # String + rawarr (ii+1-firstrow, jj+1-lcol) = char (scell.getStringValue ()); + case ctype (5) # Boolean + rawarr (ii+1-firstrow, jj+1-lcol) = scell.BooleanValue (); + otherwise + # Nothing to do here + endswitch + # Set cell type to blank to skip switch below + type_of_cell = ctype(4); + catch + # In case of formula errors we take the cached results + type_of_cell = scell.getCachedFormulaResultType (); + ++jerror; # We only need one warning even for multiple errors + end_try_catch + endif endif # Preparations done, get data values into data array switch type_of_cell case ctype(1) # 0 Numeric - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getNumericCellValue (); + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getNumericCellValue (); case ctype(2) # 1 String - rawarr (ii+1-firstrow, jj+1-lcol) = char (cell.getRichStringCellValue ()); + rawarr (ii+1-firstrow, jj+1-lcol) = char (scell.getRichStringCellValue ()); + case ctype(3) + if (spsh_opts.formulas_as_text) + tmp = char (scell.getCellFormula ()); + rawarr (ii+1-firstrow, jj+1-lcol) = ['=' tmp]; + endif case ctype(4) # 3 Blank # Blank; ignore until further notice case ctype(5) # 4 Boolean - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getBooleanCellValue (); + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getBooleanCellValue (); otherwise # 5 Error # Ignore endswitch @@ -481,9 +505,13 @@ ## Author: Philip Nienhuis ## Created: 2009-12-04 -## Last updated 2009-12-11 +## Updates: +## 2009-12-11 ??? some bug fix +## 2010-07-28 Added option to read formulas as text strings rather than evaluated value +## Added check for proper xls structure +## 2010-07-29 Added check for too latge requested data rectangle -function [ rawarr, xls, status ] = xls2jxla2oct (xls, wsh, cellrange=[]) +function [ rawarr, xls, status ] = xls2jxla2oct (xls, wsh, cellrange=[], spsh_opts) persistent ctype; if (isempty (ctype)) @@ -542,47 +570,59 @@ # Translate range to HSSF POI row & column numbers [dummy, nrows, ncols, trow, lcol] = parse_sp_range (cellrange); firstrow = max (trow-1, firstrow); - lastrow = firstrow + nrows - 1; lcol = lcol - 1; # POI rows & column # 0-based + # Check for too large requested range against actually present range + lastrow = min (firstrow + nrows - 1, sh.getRows () - 1); + nrows = min (nrows, sh.getRows () - firstrow); + ncols = min (ncols, sh.getColumns () - lcol); endif # Read contents into rawarr rawarr = cell (nrows, ncols); # create placeholder for jj = lcol : lcol+ncols-1 for ii = firstrow:lastrow - cell = sh.getCell (jj, ii); - type_of_cell = char (cell.getType ()); - switch type_of_cell - case ctype {1, 1} - # Boolean - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getValue (); - case ctype {2, 1} - # Boolean formula - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getValue (); - case ctype {3, 1} - # Date - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getValue (); - case ctype {4, 1} - # Date Formula - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getValue (); - case ctype {5, 1} - # Empty. Nothing to do here - case ctype {6, 1} - # Error. Nothing to do here - case ctype {7, 1} - # Formula Error. Nothing to do here - case ctype {8, 1} - # Number - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getValue (); - case ctype {9, 1} - # String - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getString (); - case ctype {10, 1} - # NumericalFormula - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getValue (); - case ctype {11, 1} - # String Formula - rawarr (ii+1-firstrow, jj+1-lcol) = cell.getString (); + scell = sh.getCell (jj, ii); + switch char (scell.getType ()) + case ctype {1, 1} # Boolean + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getValue (); + case ctype {2, 1} # Boolean formula + if (spsh_opts.formulas_as_text) + tmp = scell.getFormula (); + rawarr (ii+1-firstrow, jj+1-lcol) = ["=" tmp]; + else + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getValue (); + endif + case ctype {3, 1} # Date + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getValue (); + case ctype {4, 1} # Date formula + if (spsh_opts.formulas_as_text) + tmp = scell.getFormula (); + rawarr (ii+1-firstrow, jj+1-lcol) = ["=" tmp]; + else + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getValue (); + endif + case { ctype {5, 1}, ctype {6, 1}, ctype {7, 1} } + # Empty, Error or Formula error. Nothing to do here + case ctype {8, 1} # Number + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getValue (); + case ctype {9, 1} # String + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getString (); + case ctype {10, 1} # Numerical formula + if (spsh_opts.formulas_as_text) + tmp = scell.getFormula (); + rawarr (ii+1-firstrow, jj+1-lcol) = ["=" tmp]; + else + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getValue (); + endif + case ctype {11, 1} # String formula + if (spsh_opts.formulas_as_text) + tmp = scell.getFormula (); + rawarr (ii+1-firstrow, jj+1-lcol) = ["=" tmp]; + else + rawarr (ii+1-firstrow, jj+1-lcol) = scell.getString (); + endif + otherwise + # Do nothing endswitch endfor endfor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |