changeset 12403:a8a4133c1823 octave-forge

When truncating arrays (too small range, sheet capacity limits) convey truncated range, not only topleft cell
author prnienhuis
date Tue, 18 Mar 2014 22:31:26 +0000
parents 3dbdbd700916
children a7500b0ccda0
files main/io/inst/xlswrite.m
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/main/io/inst/xlswrite.m	Tue Mar 18 22:29:45 2014 +0000
+++ b/main/io/inst/xlswrite.m	Tue Mar 18 22:31:26 2014 +0000
@@ -112,7 +112,8 @@
 ## 2012-04-17 Fix checks on xls or xls? suffix (due to Vermylen)
 ## 2012-04-21 Improve xls/xlsx suffix check
 ## 2013-12-07 Updated copyright string
-##     ''     Check on empty file ptr struct after calling xlsopen
+##     ''     Check on empty file ptr struct after calling xlsopen
+## 2014-03-18 Convey full crange to oct2xls, not just topleft
 
 function [ rstatus ] = xlswrite (filename, arr, arg3, arg4, arg5)
 
@@ -166,7 +167,10 @@
     nr = min (nrows, nr);
     nc = min (ncols, nc);
     warning ("xlswrite - array truncated to %d by %d to fit in range %s", ...
-             nrows, ncols, crange);
+             nrows, ncols, crange);
+    ## Adapt crange
+    crange = [ calccelladdress(trow, lcol) ":" ...
+               calccelladdress(trow+nrows-1, lcol+ncols-1) ];
   endif
 
   unwind_protect          ## Needed to be sure Excel can be closed i.c.o. errors
@@ -175,7 +179,7 @@
     if (! isempty (xls))
       xls_ok = 1;
 
-      [xls, rstatus] = oct2xls (arr(1:nr, 1:nc), xls, wsh, topleft);
+      [xls, rstatus] = oct2xls (arr(1:nr, 1:nc), xls, wsh, crange);
     endif
 
   unwind_protect_cleanup