Read worksheet titles and ids for a workbook
168819
def read_sheets(archive):
    """"""
    xml_source = archive.read(ARC_WORKBOOK)
    tree = fromstring(xml_source)
    for element in safe_iterator(tree, '{%s}sheet' % SHEET_MAIN_NS):
        attrib = element.attrib
        attrib['id'] = attrib["{%s}id" % REL_NS]
        del attrib["{%s}id" % REL_NS]
        if attrib['id']:
            yield attrib
1124960
public List<String> getAllSheetNames() {
    List<String> sheets = newArrayList();
    for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
      sheets.add(workbook.getSheetName(i));
    }
    return sheets;
  }
312054
def getWorksheet(self):
        
        worksheet = self.getBackReferences('WorksheetAnalysis')
        if not worksheet:
            return None
        if len(worksheet) > 1:
            logger.error(
                "Analysis %s is assigned to more than one worksheet."
                % self.getId())
        return worksheet[0]
863856
def load_data(self, filename, *args, **kwargs):
        
        # workbook read from file
        workbook = open_workbook(filename, verbosity=True)
        data = {}  # an empty dictionary to store data
        # iterate through sheets in parameters
        # iterate through the parameters on each sheet
        for param, pval in self.parameters.iteritems():
            sheet = pval['extras']['sheet']
            # get each worksheet from the workbook
            worksheet = workbook.sheet_by_name(sheet)
            # split the parameter's range elements
            prng0, prng1 = pval['extras']['range']
            # missing "units", json ``null`` and Python ``None`` all OK!
            # convert to str from unicode, None to '' (dimensionless)
            punits = str(pval.get('units') or '')
            # replace None with empty list
            if prng0 is None:
                prng0 = []
            if prng1 is None:
                prng1 = []
            # FIXME: Use duck-typing here instead of type-checking!
            # if both elements in range are `int` then parameter is a cell
            if isinstance(prng0, int) and isinstance(prng1, int):
                datum = worksheet.cell_value(prng0, prng1)
            # if the either element is a `list` then parameter is a slice
            elif isinstance(prng0, list) and isinstance(prng1, int):
                datum = worksheet.col_values(prng1, *prng0)
            elif isinstance(prng0, int) and isinstance(prng1, list):
                datum = worksheet.row_values(prng0, *prng1)
            # if both elements are `list` then parameter is 2-D
            else:
                datum = []
                for col in xrange(prng0[1], prng1[1]):
                    datum.append(worksheet.col_values(col, prng0[0],
                                                      prng1[0]))
            # duck typing that datum is real
            try:
                npdatum = np.array(datum, dtype=np.float)
            except ValueError as err:
                # check for iterable:
                # if `datum` can't be coerced to float, then it must be
                # *string* & strings *are* iterables, so don't check!
                # check for strings:
                # data must be real or *all* strings!
                # empty string, None or JSON null also OK
                # all([]) == True but any([]) == False
                if not datum:
                    data[param] = None  # convert empty to None
                elif all(isinstance(_, basestring) for _ in datum):
                    data[param] = datum  # all str is OK (EG all 'TMY')
                elif all(not _ for _ in datum):
                    data[param] = None  # convert list of empty to None
                else:
                    raise err  # raise ValueError if not all real or str
            else:
                data[param] = npdatum * UREG(punits)
            # FYI: only put one statement into try-except test otherwise
            # might catch different error than expected. use ``else`` as
            # option to execute only if exception *not* raised.
        return data
71069
def excel_todictlist(path_to_file, **kwargs):
    
    result = collections.OrderedDict()
    encoding = kwargs.get('encoding', 'utf-8')
    formatting_info = '.xlsx' not in path_to_file
    count = 0

    with xlrd.open_workbook(
        path_to_file,
        encoding_override=encoding, formatting_info=formatting_info) \
            as _excelfile:

        for sheet_name_raw in _excelfile.sheet_names():

            # if empty sheet name put sheet# as name
            sheet_name = sheet_name_raw or "sheet{}".format(count)
            result[sheet_name] = []

            xl_sheet = _excelfile.sheet_by_name(sheet_name_raw)

            for row_idx in range(0, xl_sheet.nrows):
                col_data = []
                for col_idx in range(0, xl_sheet.ncols):

                    # Get cell object by row, col
                    cell_obj = xl_sheet.cell(row_idx, col_idx)
                    merged_info = is_merged(xl_sheet, row_idx, col_idx)

                    # Search for value in merged_info
                    if not cell_obj.value and merged_info:
                        cell_obj = search_mergedcell_value(
                            xl_sheet, merged_info[1])
                        col_data.append(cell_obj.value if cell_obj else '')
                    else:
                        col_data.append(cell_obj.value)

                result[sheet_name].append(col_data)

            count += 1  # increase sheet counter

    return result
625892
public List<String> getAllSheetNames() {
    checkState(!isClosed, WORKBOOK_CLOSED);
    List<String> sheets = newArrayList();
    for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
      sheets.add(workbook.getSheetName(i));
    }
    return sheets;
  }
115033
public List<String> getSheetNames() {
		final int totalSheet = workbook.getNumberOfSheets();
		List<String> result = new ArrayList<>(totalSheet);
		for (int i = 0; i < totalSheet; i++) {
			result.add(this.workbook.getSheetAt(i).getSheetName());
		}
		return result;
	}
573574
def [](ind)
      case ind
      when Integer then worksheets[ind]
      when String  then worksheets.find { |ws| ws.sheet_name == ind }
      end
    end
692713
def read_excel(
    filename: PathLike,
    sheet: Union[str, int],
    dtype: str='float32',
) -> AnnData:
    
    # rely on pandas for reading an excel file
    from pandas import read_excel
    df = read_excel(fspath(filename), sheet)
    X = df.values[:, 1:]
    row = {'row_names': df.iloc[:, 0].values.astype(str)}
    col = {'col_names': np.array(df.columns[1:], dtype=str)}
    return AnnData(X, row, col, dtype=dtype)
1238431
def read_excel_file(inputfile, sheet_name):
    
    workbook = xlrd.open_workbook(inputfile)
    output = []
    found = False
    for sheet in workbook.sheets():
        if sheet.name == sheet_name:
            found = True
            for row in range(sheet.nrows):
                values = []
                for col in range(sheet.ncols):
                    values.append(sheet.cell(row, col).value)
                output.append(values)
    if not found:  # pragma: no cover
        raise MQ2Exception('Invalid session identifier provided')
    return output
307383
public function listWorksheetNames($pFilename)
    {
        // Check if file exists
        if (!file_exists($pFilename)) {
            throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
        }

        $worksheetNames = array();

        // Read the OLE file
        $this->loadOLE($pFilename);

        // total byte size of Excel data (workbook global substream + sheet substreams)
        $this->dataSize = strlen($this->data);

        $this->pos        = 0;
        $this->sheets    = array();

        // Parse Workbook Global Substream
        while ($this->pos < $this->dataSize) {
            $code = self::getInt2d($this->data, $this->pos);

            switch ($code) {
                case self::XLS_TYPE_BOF:
                    $this->readBof();
                    break;
                case self::XLS_TYPE_SHEET:
                    $this->readSheet();
                    break;
                case self::XLS_TYPE_EOF:
                    $this->readDefault();
                    break 2;
                default:
                    $this->readDefault();
                    break;
            }
        }

        foreach ($this->sheets as $sheet) {
            if ($sheet['sheetType'] != 0x00) {
                // 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module
                continue;
            }

            $worksheetNames[] = $sheet['name'];
        }

        return $worksheetNames;
    }
433533
def __set_sheet_filenames(sheets, n):
    
    try:
        for idx, sheet in enumerate(sheets):
            try:
                sheets[idx]["filename"] = "{}.{}".format(n, sheet["filename"])
            except Exception as e:
                logger_excel.error("set_sheet_filenames: inner: {}".format(e), exc_info=True)
    except Exception as q:
        logger_excel.error("set_sheet_filenames: outer: {}".format(q), exc_info=True)
    return sheets
911726
def get_worksheet(self, id_or_name):
        
        url = self.build_url(self._endpoints.get('get_worksheet').format(id=quote(id_or_name)))
        response = self.session.get(url)
        if not response:
            return None
        return self.worksheet_constructor(parent=self, **{self._cloud_data_key: response.json()})
1102767
def sheets(self):
        
        # http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XSpreadsheetDocument.html#getSheets
        try:
            return self._sheets
        except AttributeError:
            target = self._target.getSheets()
            self._sheets = SpreadsheetCollection(self, target)
        return self._sheets
596273
def write_data(worksheet, data):
    
    if not data:
        return

    if isinstance(data, list):
        rows = data
    else:
        rows = [data]

    if isinstance(rows[0], dict):
        keys = get_keys(rows)
        worksheet.append([utilities.convert_snake_to_title_case(key) for key in keys])
        for row in rows:
            values = [get_value_from_row(row, key) for key in keys]
            worksheet.append(values)
    elif isinstance(rows[0], list):
        for row in rows:
            values = [utilities.normalize_cell_value(value) for value in row]
            worksheet.append(values)
    else:
        for row in rows:
            worksheet.append([utilities.normalize_cell_value(row)])
238004
def get_worksheets_section(self):
        
        out = []
        bc = getToolByName(self.context, CATALOG_WORKSHEET_LISTING)
        query = {'portal_type': "Worksheet", }

        # Check if dashboard_cookie contains any values to query
        # elements by
        query = self._update_criteria_with_filters(query, 'worksheets')

        # Active Worksheets (all)
        total = self.search_count(query, bc.id)

        # Open worksheets
        name = _('Results pending')
        desc = _('Results pending')
        purl = 'worksheets?list_review_state=open'
        query['review_state'] = ['open', 'attachment_due']
        out.append(self._getStatistics(name, desc, purl, bc, query, total))

        # Worksheets to be verified
        name = _('To be verified')
        desc = _('To be verified')
        purl = 'worksheets?list_review_state=to_be_verified'
        query['review_state'] = ['to_be_verified', ]
        out.append(self._getStatistics(name, desc, purl, bc, query, total))

        # Worksheets verified
        name = _('Verified')
        desc = _('Verified')
        purl = 'worksheets?list_review_state=verified'
        query['review_state'] = ['verified', ]
        out.append(self._getStatistics(name, desc, purl, bc, query, total))

        # Chart with the evolution of WSs over a period, grouped by
        # periodicity
        outevo = self.fill_dates_evo(bc, query)
        out.append({'type':         'bar-chart-panel',
                    'name':         _('Evolution of Worksheets'),
                    'class':        'informative',
                    'description':  _('Evolution of Worksheets'),
                    'data':         json.dumps(outevo),
                    'datacolors':   json.dumps(self.get_colors_palette())})

        return {'id': 'worksheets',
                'title': _('Worksheets'),
                'panels': out}
1298190
def read_excel(input_fpath):
    
    return {k: v.values for k, v in pd.read_excel(input_fpath).items()}