/usr/share/octave/packages/io-2.4.5/private/__POI_getusedrange__.m is in octave-io 2.4.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | ## Copyright (C) 2010-2016 Philip Nienhuis
##
## 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 the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.
## __POI_getusedrange__ - get range of occupied data cells from Excel using java/POI
## Author: Philip Nienhuis <prnienhuis at users.sf.net>
## Created: 2010-03-20
function [ trow, brow, lcol, rcol ] = __POI_getusedrange__ (xls, ii)
persistent cblnk;
cblnk = __java_get__ ("org.apache.poi.ss.usermodel.Cell", "CELL_TYPE_BLANK");
sh = xls.workbook.getSheetAt (ii-1); ## Java POI starts counting at 0
trow = sh.getFirstRowNum (); ## 0-based
brow = sh.getLastRowNum (); ## 0-based
## Get column range
lcol = 1048577; ## OOXML (xlsx) max. + 1
rcol = 0;
botrow = brow;
for jj=trow:brow
irow = sh.getRow (jj);
if (! isempty (irow))
scol = irow.getFirstCellNum;
## If getFirstCellNum < 0, row is empty
if (scol >= 0)
lcol = min (lcol, scol);
ecol = irow.getLastCellNum - 1;
rcol = max (rcol, ecol);
## Keep track of lowermost non-empty row as getLastRowNum() is unreliable
if (! (irow.getCell(scol).getCellType () == cblnk ...
&& irow.getCell(ecol).getCellType () == cblnk))
botrow = jj;
endif
endif
endif
endfor
if (lcol > 1048576)
## Empty sheet
trow = 0; brow = 0; lcol = 0; rcol = 0;
else
## 1-based retvals
brow = min (brow, botrow) + 1;
++trow;
++lcol;
++rcol;
endif
endfunction
|