Returns xls workbook object with everything from code_array
480251
def from_code_array(self):
        """"""

        worksheets = []
        self._shape2xls(worksheets)

        self._code2xls(worksheets)

        self._row_heights2xls(worksheets)
        self._col_widths2xls(worksheets)

        return self.workbook
377328
async function toExcel(opts) {
  const { collection, documents, columns, stream, filename } = opts;
  const workbook = new Excel.stream.xlsx.WorkbookWriter({
    stream,
    filename,
    useStyles: true,
    useSharedStrings: true
  });

  workbook.created = new Date();
  workbook.modified = new Date();

  const sheet = workbook.addWorksheet('sheet 1');

  sheet.columns = columns.map(column => {
    const path = column.field;
    const namePath = collection.parsePath(path);

    return {
      header: column.label || namePath.pathLabel,
      key: path,
      width: 10
    };
  });

  for (const document of documents) {
    const row = {};

    for (const column of columns) {
      const path = column.field;
      const namePath = collection.parsePath(path);

      row[path] = namePath.get(document);
    }

    sheet.addRow(row).commit();
  }

  sheet.commit();

  await workbook.commit();
}
88182
def wr_data(self, xlsx_data, row_i, worksheet):
        """"""
        fld2fmt = self.vars.fld2fmt
        # User may specify to skip rows based on values in row
        prt_if = self.vars.prt_if
        # User may specify a subset of columns to print or
        # a column ordering different from the _fields seen in the namedtuple
        prt_flds = self.wbfmtobj.get_prt_flds()
        get_wbfmt = self.wbfmtobj.get_wbfmt
        if self.vars.sort_by is not None:
            xlsx_data = sorted(xlsx_data, key=self.vars.sort_by)
        try:
            for data_nt in xlsx_data:
                if prt_if is None or prt_if(data_nt):
                    wbfmt = get_wbfmt(data_nt)  # xlsxwriter.format.Format created w/add_format
                    # Print an xlsx row by printing each column in order.
                    for col_i, fld in enumerate(prt_flds):
                        try:
                            # If fld "format_txt" present, use val for formatting, but don't print.
                            val = getattr(data_nt, fld, "")
                            # Optional user-formatting of specific fields, eg, pval: "{:8.2e}"
                            # If field value is empty (""), don't use fld2fmt
                            if fld2fmt is not None and fld in fld2fmt and val != "" and val != "*":
                                val = fld2fmt[fld].format(val)
                            worksheet.write(row_i, col_i, val, wbfmt)
                        except:
                            raise RuntimeError(self._get_err_msg(row_i, col_i, fld, val, prt_flds))
                    row_i += 1
        except RuntimeError as inst:
            import traceback
            traceback.print_exc()
            sys.stderr.write("\n  **FATAL in wr_data: {MSG}\n\n".format(MSG=str(inst)))
            sys.exit(1)
        return row_i
257519
def to_xlsx(self, **kwargs):
        
        from xlsxwriter.workbook import Workbook as _Workbook
        self.workbook_obj = _Workbook(**kwargs)
        self.workbook_obj.set_calc_mode(self.calc_mode)

        for worksheet in self.itersheets():
            worksheet.to_xlsx(workbook=self)

        self.workbook_obj.filename = self.filename
        if self.filename:
            self.workbook_obj.close()
        return self.workbook_obj
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
637290
def _save_xls(self, filepath):
        

        Interface = self.type2interface["xls"]

        workbook = xlwt.Workbook()
        interface = Interface(self.grid.code_array, workbook)
        interface.from_code_array()

        try:
            workbook.save(filepath)

        except IOError, err:
            try:
                post_command_event(self.main_window, self.StatusBarMsg,
                                   text=err)
            except TypeError:
                # The main window does not exist any more
                pass
400292
function parse_wb_bin(data, opts) {
	var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
	var state = [];
	var pass = false;

	if(!opts) opts = {};
	opts.biff = 12;

	var Names = [];
	var supbooks = ([[]]);
	supbooks.SheetNames = [];
	supbooks.XTI = [];

	recordhopper(data, function hopper_wb(val, R_n, RT) {
		switch(RT) {
			case 0x009C: /* 'BrtBundleSh' */
				supbooks.SheetNames.push(val.name);
				wb.Sheets.push(val); break;

			case 0x0099: /* 'BrtWbProp' */
				wb.WBProps = val; break;

			case 0x0027: /* 'BrtName' */
				if(val.Sheet != null) opts.SID = val.Sheet;
				val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
				delete opts.SID;
				delete val.Ptg;
				Names.push(val);
				break;
			case 0x040C: /* 'BrtNameExt' */ break;

			case 0x0165: /* 'BrtSupSelf' */
			case 0x0166: /* 'BrtSupSame' */
			case 0x0163: /* 'BrtSupBookSrc' */
			case 0x029B: /* 'BrtSupAddin' */
				if(!supbooks[0].length) supbooks[0] = [RT, val];
				else supbooks.push([RT, val]);
				supbooks[supbooks.length - 1].XTI = [];
				break;
			case 0x016A: /* 'BrtExternSheet' */
				if(supbooks.length === 0) { supbooks[0] = []; supbooks[0].XTI = []; }
				supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);
				supbooks.XTI = supbooks.XTI.concat(val);
				break;
			case 0x0169: /* 'BrtPlaceholderName' */
				break;

			/* case 'BrtModelTimeGroupingCalcCol' */
			case 0x0C00: /* 'BrtUid' */
			case 0x0C01: /* 'BrtRevisionPtr' */
			case 0x0817: /* 'BrtAbsPath15' */
			case 0x0216: /* 'BrtBookProtection' */
			case 0x02A5: /* 'BrtBookProtectionIso' */
			case 0x009E: /* 'BrtBookView' */
			case 0x009D: /* 'BrtCalcProp' */
			case 0x0262: /* 'BrtCrashRecErr' */
			case 0x0802: /* 'BrtDecoupledPivotCacheID' */
			case 0x009B: /* 'BrtFileRecover' */
			case 0x0224: /* 'BrtFileSharing' */
			case 0x02A4: /* 'BrtFileSharingIso' */
			case 0x0080: /* 'BrtFileVersion' */
			case 0x0299: /* 'BrtFnGroup' */
			case 0x0850: /* 'BrtModelRelationship' */
			case 0x084D: /* 'BrtModelTable' */
			case 0x0225: /* 'BrtOleSize' */
			case 0x0805: /* 'BrtPivotTableRef' */
			case 0x0254: /* 'BrtSmartTagType' */
			case 0x081C: /* 'BrtTableSlicerCacheID' */
			case 0x081B: /* 'BrtTableSlicerCacheIDs' */
			case 0x0822: /* 'BrtTimelineCachePivotCacheID' */
			case 0x018D: /* 'BrtUserBookView' */
			case 0x009A: /* 'BrtWbFactoid' */
			case 0x045D: /* 'BrtWbProp14' */
			case 0x0229: /* 'BrtWebOpt' */
			case 0x082B: /* 'BrtWorkBookPr15' */
				break;

			case 0x0023: /* 'BrtFRTBegin' */
				state.push(R_n); pass = true; break;
			case 0x0024: /* 'BrtFRTEnd' */
				state.pop(); pass = false; break;
			case 0x0025: /* 'BrtACBegin' */
				state.push(R_n); pass = true; break;
			case 0x0026: /* 'BrtACEnd' */
				state.pop(); pass = false; break;

			case 0x0010: /* 'BrtFRTArchID$' */ break;

			default:
				if((R_n||"").indexOf("Begin") > 0){/* empty */}
				else if((R_n||"").indexOf("End") > 0){/* empty */}
				else if(!pass || (opts.WTF && state[state.length-1] != "BrtACBegin" && state[state.length-1] != "BrtFRTBegin")) throw new Error("Unexpected record " + RT + " " + R_n);
		}
	}, opts);

	parse_wb_defaults(wb);

	// $FlowIgnore
	wb.Names = Names;

	(wb).supbooks = supbooks;
	return wb;
}
953878
def extract_object_names_from_docs(filename):
    """"""
    text = split_code_and_text_blocks(filename)[1]
    text = '\n'.join(t[1] for t in text if t[0] == 'text')
    regex = re.compile(r':(?:'
                       r'func(?:tion)?|'
                       r'meth(?:od)?|'
                       r'attr(?:ibute)?|'
                       r'obj(?:ect)?|'
                       r'class):`(\S*)`'
                       )
    return [(x, x) for x in re.findall(regex, text)]
175403
def _xls2code(self, worksheet, tab):
        """"""

        def xlrddate2datetime(xlrd_date):
            """Returns datetime from xlrd_date"""

            try:
                xldate_tuple = xlrd.xldate_as_tuple(xlrd_date,
                                                    self.workbook.datemode)
                return datetime(xldate_tuple)

            except (ValueError, TypeError):
                return ''

        type2mapper = {
            0: lambda x: None,  # Empty cell
            1: lambda x: str(x),  # Text cell
            2: lambda x: str(x),  # Number cell
            3: xlrddate2datetime,  # Date
            4: lambda x: str(bool(x)),  # Boolean cell
            5: lambda x: str(x),  # Error cell
            6: lambda x: None,  # Blank cell
        }

        rows, cols = worksheet.nrows, worksheet.ncols
        for row, col in product(xrange(rows), xrange(cols)):
            cell_type = worksheet.cell_type(row, col)
            cell_value = worksheet.cell_value(row, col)

            key = row, col, tab
            mapper = type2mapper[cell_type]
            self.code_array[key] = mapper(cell_value)
616534
def wr_xlsx_gos(self, fout_xlsx, **kws_usr):
        """"""
        # Keyword arguments: control content
        desc2nts = self.sortobj.get_desc2nts(**kws_usr)
        # Keyword arguments: control xlsx format
        self.wr_xlsx_nts(fout_xlsx, desc2nts, **kws_usr)
        return desc2nts
381550
def csv(args):
    
    from xlrd import open_workbook

    p = OptionParser(csv.__doc__)
    p.set_sep(sep=',')
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    excelfile, = args
    sep = opts.sep
    csvfile = excelfile.rsplit(".", 1)[0] + ".csv"
    wb = open_workbook(excelfile)
    fw = open(csvfile, "w")
    for s in wb.sheets():
        print('Sheet:',s.name, file=sys.stderr)
        for row in range(s.nrows):
            values = []
            for col in range(s.ncols):
                values.append(s.cell(row, col).value)
            print(sep.join(str(x) for x in values), file=fw)
356258
public static String[] getXlsxWorksheets(File file) 
        throws IOException
    {
        XlsxWorkbook workbook = XlsxWorkbook.getWorkbook(file);
        String[] sheets = workbook.getSheetNames();
        workbook.close();
        return sheets;
    }
351918
def export_xlsx(self, key):
        
        spreadsheet_file = self.client.files().get(fileId=key).execute()
        links = spreadsheet_file.get('exportLinks')
        downloadurl = links.get('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
        resp, content = self.client._http.request(downloadurl)
        return content
1125604
def _xls2shape(self):
        """"""

        sheets = self.workbook.sheets()
        nrows = 1
        ncols = 1
        for sheet in sheets:
            nrows = max(nrows, sheet.nrows)
            ncols = max(ncols, sheet.ncols)
        ntabs = len(sheets)

        self.code_array.shape = nrows, ncols, ntabs
1059857
def usufyToXlsExport(d, fPath):
    
    from pyexcel_xls import get_data
    try:
        #oldData = get_data(fPath)
        # A change in the API now returns only an array of arrays if there is only one sheet.
        oldData = {"OSRFramework": get_data(fPath) }
    except:
        # No information has been recovered
        oldData = {"OSRFramework":[]}

    # Generating the new tabular data
    tabularData = _generateTabularData(d, oldData)
    from pyexcel_xls import save_data
    # Storing the file
    save_data(fPath, tabularData)
228269
def _col_widths2xls(self, worksheets):
        

        xls_max_cols, xls_max_tabs = self.xls_max_cols, self.xls_max_tabs

        dict_grid = self.code_array.dict_grid

        for col, tab in dict_grid.col_widths:
            if col < xls_max_cols and tab < xls_max_tabs:
                pys_width = dict_grid.col_widths[(col, tab)]
                xls_width = self.pys_width2xls_width(pys_width)
                worksheets[tab].col(col).width = xls_width
879086
def extract_code_objects(pe):
    """"""
    script_res = _get_scripts_resource(pe)
    dump = _resource_dump(pe, script_res)
    return _get_co_from_dump(dump)