convert xlwt Workbook instance to a BytesIO instance
320250
def xlsx_to_strio(xlsx_wb):
    
    _xlrd_required()
    fh = BytesIO()
    xlsx_wb.filename = fh
    xlsx_wb.close()
    # prep for reading
    fh.seek(0)
    return fh
599735
def BytesIO(*args, **kwargs):
    """"""
    raw = sync_io.BytesIO(*args, **kwargs)
    return AsyncBytesIOWrapper(raw)
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
3127
static OutputStream toXlsxFile(final IDataSet dataSet) {
        ByteArrayOutputStream xlsx = new ByteArrayOutputStream();
        
        try { toWorkbook(dataSet, (Workbook) null).write(xlsx); }
        catch (IOException e) { throw new CalculationEngineException(e); }
        
        return xlsx;
    }
456313
def convert_bam_to_bed(in_bam, out_file):
    
    with file_transaction(out_file) as tx_out_file:
        with open(tx_out_file, "w") as out_handle:
            subprocess.check_call(["bamToBed", "-i", in_bam, "-tag", "NM"],
                                  stdout=out_handle)
    return out_file
847341
def convert_notebook(self, fname):
        """"""
        try: 
            script = nbexporter().from_filename(fname)[0]
        except Exception as e:
            QMessageBox.critical(self, _('Conversion error'), 
                                 _("It was not possible to convert this "
                                 "notebook. The error is:\n\n") + \
                                 to_text_string(e))
            return
        self.sig_new_file.emit(script)
158650
static IDataModel toDataModel(final Workbook workbook) {
        if (workbook == null) { return null; }
        
        //add custom functions information
        workbook.addToolPack(getUdfFinder());
        
        Sheet s = workbook.getSheetAt(0); //TODO: only one sheet is supported
        if (s == null) { return null; }
        
        IDataModel dm = new DataModel(s.getSheetName());
        
        for (int i = s.getFirstRowNum(); i <= s.getLastRowNum(); i++) {
            Row r = s.getRow(i);
            if (r == null) { continue; }
            
            DmRow row = new DmRow(i);
            dm.setRow(i, row);
            
            for (int j = r.getFirstCellNum(); j < r.getLastCellNum(); j++) {
                Cell c = r.getCell(j);
                if (c == null) { continue; }
                
                DmCell cell = new DmCell();
                row.setCell(j, cell);
                
                cell.setAddress(new CellAddress(dm.getDataModelId(), A1Address.fromRowColumn(i, j)));
                cell.setContent(ConverterUtils.resolveCellValue(c));
            }
        }

        EvaluationWorkbook evaluationWbook = ConverterUtils.newEvaluationWorkbook(workbook);

        for (int nIdx = 0; nIdx < workbook.getNumberOfNames(); nIdx++) {
            Name name = workbook.getNameAt(nIdx);

            String reference = name.getRefersToFormula();
            if (reference == null) { continue; }

            if (A1Address.isAddress(removeSheetFromNameRef(reference))) {
                dm.setNamedAddress(name.getNameName(), A1Address.fromA1Address(removeSheetFromNameRef(reference)));
            } else if (isFormula(reference, evaluationWbook)) {
                dm.setNamedValue(name.getNameName(), new CellValue(FORMULA_PREFIX + reference));
            } else {
                dm.setNamedValue(name.getNameName(), CellValue.from(reference));
            }
        }

        return dm;
    }
311132
def export_to_xls(table, filename_or_fobj=None, sheet_name="Sheet1", *args, **kwargs):
    """"""

    workbook = xlwt.Workbook()
    sheet = workbook.add_sheet(sheet_name)

    prepared_table = prepare_to_export(table, *args, **kwargs)

    field_names = next(prepared_table)
    for column_index, field_name in enumerate(field_names):
        sheet.write(0, column_index, field_name)

    _convert_row = _python_to_xls([table.fields.get(field) for field in field_names])
    for row_index, row in enumerate(prepared_table, start=1):
        for column_index, (value, data) in enumerate(_convert_row(row)):
            sheet.write(row_index, column_index, value, **data)

    return_result = False
    if filename_or_fobj is None:
        filename_or_fobj = BytesIO()
        return_result = True

    source = Source.from_file(filename_or_fobj, mode="wb", plugin_name="xls")
    workbook.save(source.fobj)
    source.fobj.flush()

    if return_result:
        source.fobj.seek(0)
        result = source.fobj.read()
    else:
        result = source.fobj

    if source.should_close:
        source.fobj.close()

    return result
635575
def from_notebook_node(self, nb, resources=None, **kw):
        """"""
        from weasyprint import HTML, CSS

        nb = copy.deepcopy(nb)

        output, resources = super(OneCodexPDFExporter, self).from_notebook_node(
            nb, resources=resources, **kw
        )
        buf = BytesIO()
        HTML(string=output).write_pdf(
            buf, stylesheets=[CSS(os.path.join(ASSETS_PATH, CSS_TEMPLATE_FILE))]
        )
        buf.seek(0)
        return buf.read(), resources
653404
def to_code_array(self):
        """"""

        self._xls2shape()

        worksheets = self.workbook.sheet_names()

        for tab, worksheet_name in enumerate(worksheets):
            worksheet = self.workbook.sheet_by_name(worksheet_name)
            self._xls2code(worksheet, tab)
            self._xls2attributes(worksheet, tab)
            self._xls2row_heights(worksheet, tab)
            self._xls2col_widths(worksheet, tab)
211389
public static Workbook getWorkbook(File file) throws IOException
    {
        Workbook ret = null;
        String lowerFilename = file.getName().toLowerCase();
        if(lowerFilename.endsWith("."+CommonFiles.XLS_EXT))
        {
            ret = XlsWorkbook.getWorkbook(file);
        }
        else if(lowerFilename.endsWith("."+CommonFiles.XLSX_EXT))
        {
            XlsxWorkbook.initJaxbContexts();
            ret = XlsxWorkbook.getWorkbook(file);
        }
        return ret;
    }
1046197
public static Workbook getWorkbook(String filename, InputStream stream) 
        throws IOException
    {
        Workbook ret = null;
        String lowerFilename = filename.toLowerCase();
        if(lowerFilename.endsWith("."+CommonFiles.XLS_EXT))
        {
            ret = XlsWorkbook.getWorkbook(stream);
        }
        else if(lowerFilename.endsWith("."+CommonFiles.XLSX_EXT))
        {
            XlsxWorkbook.initJaxbContexts();
            ret = XlsxWorkbook.getWorkbook(stream);
        }
        return ret;
    }
238700
public static XlsWorkbook getWorkbook(InputStream stream) throws IOException
    {
        try
        {
            return new XlsWorkbook(stream);
        }
        catch(jxl.read.biff.BiffException e)
        {
            throw new IOException(e);
        }
    }
1222957
def from_bytes(cls, b):
		
		im = cls()
		im.chunks = list(parse_chunks(b))
		im.init()
		return im
318833
def bytes_to_file(input_data, output_file):
    """"""
    pathlib.Path(output_file.parent).mkdir(parents=True, exist_ok=True)

    with open(output_file, "wb") as file:
        file.write(input_data)
1201222
function write_BrtFileVersion(data, o) {
	if(!o) o = new_buf(127);
	for(var i = 0; i != 4; ++i) o.write_shift(4, 0);
	write_XLWideString("SheetJS", o);
	write_XLWideString(XLSX.version, o);
	write_XLWideString(XLSX.version, o);
	write_XLWideString("7262", o);
	o.length = o.l;
	return o.length > o.l ? o.slice(0, o.l) : o;
}
948439
def _to_addr(worksheet, row, col, row_fixed=False, col_fixed=False):
    """"""
    addr = ""
    A = ord('A')
    col += 1
    while col > 0:
        addr = chr(A + ((col - 1) % 26)) + addr
        col = (col - 1) // 26

    prefix = ("'%s'!" % worksheet) if worksheet else ""
    col_modifier = "$" if col_fixed else ""
    row_modifier = "$" if row_fixed else ""
    return prefix + "%s%s%s%d" % (col_modifier, addr, row_modifier, row+1)