Mercurial > forge
changeset 9525:0489a048e6ab octave-forge
More range check fixes; layout; copyright statements updated
author | prnienhuis |
---|---|
date | Mon, 27 Feb 2012 19:28:40 +0000 |
parents | c6a8104416b0 |
children | 72c7286337c9 |
files | main/io/inst/oct2ods.m main/io/inst/oct2xls.m |
diffstat | 2 files changed, 39 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/main/io/inst/oct2ods.m Mon Feb 27 11:09:00 2012 +0000 +++ b/main/io/inst/oct2ods.m Mon Feb 27 19:28:40 2012 +0000 @@ -113,12 +113,14 @@ ## 2011-11-18 Fixed bug in test for range parameter being character string ## 2012-01-26 Fixed "seealso" help string ## 2012-02-20 Fixed range parameter to be default empty string rather than empty numeral +## 2012-02-27 More range arg fixes ## ## Last update of subfunctions below: 2012-02-26 function [ ods, rstatus ] = oct2ods (c_arr, ods, wsh=1, crange='', spsh_opts=[]) if (nargin < 2) error ("oct2xls needs a minimum of 2 arguments."); endif + # Check if input array is cell if (isempty (c_arr)) warning ("Request to write empty matrix - ignored."); @@ -133,7 +135,8 @@ error ("oct2ods: input array neither cell nor numeric array"); endif if (ndims (c_arr) > 2), error ("Only 2-dimensional arrays can be written to spreadsheet"); endif - # Check ods file pointer struct + + # Check ods file pointer struct test1 = ~isfield (ods, "xtype"); test1 = test1 || ~isfield (ods, "workbook"); test1 = test1 || isempty (ods.workbook); @@ -141,10 +144,17 @@ if test1 error ("Arg #2: Invalid ods file pointer struct"); endif + # Check worksheet ptr if (~(ischar (wsh) || isnumeric (wsh))), error ("Integer (index) or text (wsh name) expected for arg # 3"); endif + # Check range - if (~isempty (crange) && ~ischar (crange)), error ("Character string (range) expected for arg # 4"); endif + if (~isempty (crange) && ~ischar (crange)) + error ("Character string (range) expected for arg # 4"); + elseif (isempty (crange)) + crange = ''; + endif + # Various options if (isempty (spsh_opts)) spsh_opts.formulas_as_text = 0;
--- a/main/io/inst/oct2xls.m Mon Feb 27 11:09:00 2012 +0000 +++ b/main/io/inst/oct2xls.m Mon Feb 27 19:28:40 2012 +0000 @@ -109,6 +109,7 @@ ## 2011-11-18 Fixed another bug in test for range parameter being character string ## 2012-01-26 Fixed "seealso" help string ## 2012-02-20 Fixed range parameter to be default empty string rather than empty numeral +## 2012-02-27 More range param fixes ## Last script file update (incl. subfunctions): 2012-02-26 @@ -139,10 +140,17 @@ if (test1) error ("Invalid xls file pointer struct"); endif + # Check worksheet ptr if (~(ischar (wsh) || isnumeric (wsh))), error ("Integer (index) or text (wsh name) expected for arg # 3"); endif + # Check range - if (~isempty (crange) && ~ischar (crange)), error ("Character string (range) expected for arg # 4"); endif + if (~isempty (crange) && ~ischar (crange)) + error ("Character string (range) expected for arg # 4"); + elseif (isempty (crange)) + crange = ''; + endif + # Various options if (isempty (spsh_opts)) spsh_opts.formulas_as_text = 0; @@ -157,23 +165,23 @@ if (nargout < 1) printf ("Warning: no output spreadsheet file pointer specified.\n"); endif # Select interface to be used - if (strcmp (xls.xtype, 'COM')) + if (strcmpi (xls.xtype, 'COM')) # Call oct2com2xls to do the work [xls, rstatus] = oct2com2xls (obj, xls, wsh, crange, spsh_opts); - elseif (strcmp (xls.xtype, 'POI')) + elseif (strcmpi (xls.xtype, 'POI')) # Invoke Java and Apache POI [xls, rstatus] = oct2jpoi2xls (obj, xls, wsh, crange, spsh_opts); - elseif (strcmp (xls.xtype, 'JXL')) + elseif (strcmpi (xls.xtype, 'JXL')) # Invoke Java and JExcelAPI [xls, rstatus] = oct2jxla2xls (obj, xls, wsh, crange, spsh_opts); - elseif (strcmp (xls.xtype, 'OXS')) -# # Invoke Java and OpenXLS ##### Not complete, saving file doesn't work yet! + elseif (strcmpi (xls.xtype, 'OXS')) + # Invoke Java and OpenXLS ##### Not complete, saving file doesn't work yet! printf ('Sorry, writing with OpenXLS not reliable => not supported yet\n'); # [xls, rstatus] = oct2oxs2xls (obj, xls, wsh, crange, spsh_opts); - elseif (strcmp (xls.xtype, 'UNO')) + elseif (strcmpi (xls.xtype, 'UNO')) # Invoke Java and UNO bridge (OpenOffice.org) [xls, rstatus] = oct2uno2xls (obj, xls, wsh, crange, spsh_opts); -# elseif (strcmp'xls.xtype, '<whatever>')) +# elseif (strcmpi (xls.xtype, '<whatever>')) # <Other Excel interfaces> else error (sprintf ("oct2xls: unknown Excel .xls interface - %s.", xls.xtype)); @@ -183,7 +191,7 @@ #=================================================================================== -## Copyright (C) 2009,2010 by Philip Nienhuis <prnienhuis@users.sf.net> +## Copyright (C) 2009,2010,2011,2012 by Philip Nienhuis <prnienhuis@users.sf.net> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -236,7 +244,7 @@ ## 2010-08-01 Added range vs. array size vs. capacity checks ## 2010-08-03 Moved range checks and type array parsing to separate functions ## 2010-10-20 Bug fix removing new empty sheets in new workbook that haven't been -## created in the first place duetoExcelsetting (thanks Ian Journeaux) +## created in the first place due to Excel setting (thanks Ian Journeaux) ## " Changed range use in COM transfer call ## 2010-10-21 Improved file change tracking (var xls.changed) ## 2010-10-24 Fixed bug introduced in above fix: for loops have no stride param, @@ -244,6 +252,7 @@ ## " Added check for "live" ActiveX server ## 2010-11-12 Moved ptr struct check into main func ## 2012-01-26 Fixed "seealso" help string +## 2012-02-27 Copyright strings updated function [ xls, status ] = oct2com2xls (obj, xls, wsh, crange, spsh_opts) @@ -415,7 +424,7 @@ #==================================================================================== -## Copyright (C) 2009,2010 Philip Nienhuis <prnienhuis at users.sf.net> +## Copyright (C) 2009,2010,2011,2012 Philip Nienhuis <prnienhuis at users.sf.net> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -472,6 +481,7 @@ ## 2010-11-12 Moved ptr struct check into main func ## 2011-11-19 Try-catch added to allow for changed method name for nr of worksheets ## 2012-01-26 Fixed "seealso" help string +## 2012-02-27 Copyright strings updated function [ xls, rstatus ] = oct2jpoi2xls (obj, xls, wsh, crange, spsh_opts) @@ -578,7 +588,7 @@ #==================================================================================== -## Copyright (C) 2009,2010 Philip Nienhuis <prnienhuis at users.sf.net> +## Copyright (C) 2009,2010,2011,2012 Philip Nienhuis <prnienhuis at users.sf.net> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -633,10 +643,11 @@ ## 2010-08-03 Moved range checks and cell type parsing to separate routines ## 2010-08-11 Moved addcell() into try-catch as it is addCell which throws fatal errors ## 2010-10-20 Improved logic for tracking file changes (xls.changed 2 or 3); dropped -## " internal variable 'changed' +## '' internal variable 'changed' ## 2010-10-27 File change tracking again refined ## 2010-11-12 Moved ptr struct check into main func ## 2012-01-26 Fixed "seealso" help string +## 2012-02-27 Copyright strings updated function [ xls, rstatus ] = oct2jxla2xls (obj, xls, wsh, crange, spsh_opts) @@ -794,7 +805,7 @@ ## Author: Philip Nienhuis <prnienhuis@users.sf.net> ## Created: 2011-03-29 ## Updates: -##oct2oxs2xls +## function [ xls, rstatus ] = oct2oxs2xls (obj, xls, wsh, crange, spsh_opts) @@ -889,7 +900,7 @@ endfunction -## Copyright (C) 2011 Philip Nienhuis <prnienhuis@users.sf.net> +## Copyright (C) 2011,2012 Philip Nienhuis <prnienhuis@users.sf.net> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -914,6 +925,7 @@ ## 2012-02-25 Fixed wrong var name in L.933 ## 2012-02-25 Catch stray Java RuntimeException when deleting sheets ## 2012-02-26 Bug fix when adding sheets near L.994 (wrong if-else-end construct). +## 2012-02-27 Copyright strings updated function [ xls, rstatus ] = oct2uno2xls (c_arr, xls, wsh, crange, spsh_opts)