xlsxの構造定義設定を解析する
327903
private function parse_definition( $objPHPExcel, $sheetIndex = 0 ){
		$rtn = array();
		$objPHPExcel->setActiveSheetIndex($sheetIndex);
		$objSheet = $objPHPExcel->getActiveSheet();

		parse_str( $objSheet->getCell('A1')->getCalculatedValue(), $rtn );

		$rtn['tbl_highest_row'] = $objSheet->getHighestRow(); // e.g. 10
		$rtn['tbl_highest_col_name'] = $objSheet->getHighestColumn(); // e.g 'F'
		$rtn['tbl_highest_col'] = \PHPExcel_Cell::columnIndexFromString( $rtn['tbl_highest_col_name'] ); // e.g. 5

		$rtn['row_definition'] = @intval($rtn['row_definition']);
		$rtn['row_data_start'] = @intval($rtn['row_data_start']);
		if( !@strlen($rtn['skip_empty_col']) ){
			// 省略されていた場合にデフォルト値を与える
			$rtn['skip_empty_col'] = 20;
		}
		$rtn['skip_empty_col'] = intval($rtn['skip_empty_col']);

		$rtn['col_define'] = array();

		$mergedCells = $objSheet->getMergeCells();
		$mergeInfo = array();
		foreach( $mergedCells as $mergeRow ){
			if( preg_match( '/^([a-zA-Z]+)'.$rtn['row_definition'].'\:([a-zA-Z]+)'.$rtn['row_definition'].'$/', $mergeRow, $matched ) ){
				$mergeInfo[$matched[1]] = $matched[2];
			}
		}

		$col = 'A';
		$skip_count = 0;
		while(1){
			$def_key = $objSheet->getCell($col.$rtn['row_definition'])->getCalculatedValue();
			if(!strlen($def_key)){
				$skip_count ++;
				$col ++;
				if( $skip_count > $rtn['skip_empty_col'] ){
					break;
				}
				continue;
			}
			$skip_count = 0;

			$rtn['col_define'][$def_key] = array(
				'key'=>trim($def_key),
				'col'=>$col,
				// 'name'=>$def_name,
			);

			if( @strlen($mergeInfo[$col]) ){
				$mergeStartCol = $mergeInfo[$col];
				while( strcmp($mergeStartCol, $col) ){
					$col ++;
				}
			}else{
				$col ++;
			}
		}

		return $rtn;
	}
542561
def set_xlsx_colwidths(worksheet, fld2col_widths, fldnames):
        """"""
        for col_idx, fld in enumerate(fldnames):
            col_width = fld2col_widths.get(fld, None)
            if col_width is not None:
                worksheet.set_column(col_idx, col_idx, col_width)
653949
private function mk_xlsx_body($objSheet, $page_info, $is_valid_parent = false){
		if(!is_array($page_info)){
			return false;
		}
		set_time_limit(30);

		$sitemap_definition = $this->get_sitemap_definition();
		$table_definition = $this->get_table_definition();

		foreach( $table_definition['col_define'] as $def_row ){
			$cellName = ($def_row['col']).$this->current_row;
			$cellValue = @$page_info[$def_row['key']];
			switch($def_row['key']){
				case 'title_h1':
				case 'title_label':
				case 'title_breadcrumb':
					if($cellValue == $page_info['title']){
						$cellValue = '';
					}
					$objSheet->getCell($cellName)->setValue($cellValue);

					// 罫線の一括指定
					$objSheet->getStyle($cellName)->applyFromArray( $this->default_cell_style_boarder );
					break;
				case 'title':
					// 罫線を引く
					$tmp_col = $def_row['col'];
					for($i = 0; $i <= $this->get_max_depth(); $i ++ ){
						$tmp_border_style = array(
							'borders' => array(
								'top'     => array('style' => \PHPExcel_Style_Border::BORDER_THIN),
								'bottom'  => array('style' => \PHPExcel_Style_Border::BORDER_THIN),
								'left'    => array('style' => \PHPExcel_Style_Border::BORDER_THIN),
								'right'   => array('style' => \PHPExcel_Style_Border::BORDER_THIN, 'color'=>array('rgb'=>'dddddd')),
							)
						);
						if($i != 0){
							$tmp_border_style['borders']['left']['style'] = \PHPExcel_Style_Border::BORDER_THIN;
							$tmp_border_style['borders']['left']['color'] = array('rgb'=>'dddddd');
						}
						if($i == $this->get_max_depth()){
							$tmp_border_style['borders']['right']['style'] = \PHPExcel_Style_Border::BORDER_THIN;
						}
						$objSheet->getStyle($tmp_col.$this->current_row)->applyFromArray( $tmp_border_style );
						$tmp_col ++;
					}
					unset($tmp_col);

					if( !strlen($page_info['id']) ){
						// トップページには細工をしない
					}elseif( !$is_valid_parent ){
						// サイトマップツリーが正常につながっていない場合
						// トップページと同じ列に並べる
					}elseif( !strlen($page_info['logical_path']) ){
						// トップページ以外でパンくず欄が空白のものは、
						// 第2階層
						$def_row['col'] ++;
					}else{
						$tmp_breadcrumb = explode('>',$page_info['logical_path']);
						for($i = 0; $i <= count($tmp_breadcrumb); $i ++ ){
							$def_row['col'] ++;
						}
					}
					$cellName = ($def_row['col']).$this->current_row;

					$objSheet->getCell($cellName)->setValue($cellValue);
					$objSheet->getStyle($cellName)->applyFromArray( array('borders'=>array(
						'left'=>array( 'color'=>array('rgb'=>'666666') ) ,
					)) );

					// 罫線の一括指定
					// $objSheet->getStyle($cellName)->applyFromArray( $this->default_cell_style_boarder );
					break;
				case 'content':
					if($cellValue == $page_info['path']){
						$cellValue = '';
					}
					$objSheet->getCell($cellName)->setValue($cellValue);

					// 罫線の一括指定
					$objSheet->getStyle($cellName)->applyFromArray( $this->default_cell_style_boarder );
					break;
				case 'path':
					$objSheet->getCell($cellName)->setValue($this->repair_path($cellValue));

					// 罫線の一括指定
					$objSheet->getStyle($cellName)->applyFromArray( $this->default_cell_style_boarder );
					break;
				case 'id':
					$objSheet->getCell($cellName)->setValue($this->repair_page_id($cellValue, $page_info['path']));

					// 罫線の一括指定
					$objSheet->getStyle($cellName)->applyFromArray( $this->default_cell_style_boarder );
					break;
				case 'keywords':
				case 'description':
					$objSheet->getCell($cellName)->setValue($cellValue);

					// フォントサイズ
					$objSheet->getStyle($cellName)->getFont()->setSize(9);

					// 罫線の一括指定
					$objSheet->getStyle($cellName)->applyFromArray( $this->default_cell_style_boarder );
					break;
				case 'logical_path':
					if( !$is_valid_parent ){
						// サイトマップツリーが正常につながっていない場合だけ記述する
						$objSheet->getCell($cellName)->setValue($cellValue);
					}
					// 罫線の一括指定
					$objSheet->getStyle($cellName)->applyFromArray( $this->default_cell_style_boarder );
					break;
				default:
					$objSheet->getCell($cellName)->setValue($cellValue);

					// 罫線の一括指定
					$objSheet->getStyle($cellName)->applyFromArray( $this->default_cell_style_boarder );
					break;
			}
		}

		return true;
	}
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
356258
public static String[] getXlsxWorksheets(File file) 
        throws IOException
    {
        XlsxWorkbook workbook = XlsxWorkbook.getWorkbook(file);
        String[] sheets = workbook.getSheetNames();
        workbook.close();
        return sheets;
    }
847337
public void generateXls(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
        try {
            Workbook wb = new HSSFWorkbook();  // or new XSSFWorkbook();
            String safeName = WorkbookUtil.createSafeSheetName("Report"); // returns " O'Brien's sales   "
            Sheet reportSheet = wb.createSheet(safeName);

            short rowc = 0;
            Row nrow = reportSheet.createRow(rowc++);
            short cellc = 0;
            if (rows == null) return;
            if (columns == null && rows.size() > 0)
            {
                columns = new ArrayList<ColumnDef>(CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
                    @Override
                    public Object transform(final Object input) {
                        return new ColumnDef()
                        {{
                                setName((String)input);
                            }};
                    }
                }));
            }
            if (columns != null)
            {
                for (ColumnDef column : columns)
                {
                    Cell cell = nrow.createCell(cellc++);
                    cell.setCellValue(column.getName());
                }
            }
            for (Map<String, Object> row : rows)
            {
                nrow = reportSheet.createRow(rowc++);
                cellc = 0;
                for (ColumnDef column : columns)
                {
                    Cell cell = nrow.createCell(cellc++);
                    cell.setCellValue(String.valueOf(row.get(column.getName())));
                }
            }
            wb.write(out);
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

    }
76652
def wr_xlsx(self, fout_xlsx, goids, sortby=None, **kws_usr):
        """"""
        nts = GoSubDag(goids, self.go2obj).get_nts(goids, sortby)
        kws_wr = kws_usr.copy()
        if 'fld2col_widths' not in kws_wr:
            kws_wr['fld2col_widths'] = self.fld2col_widths
        wr_xlsx_tbl(fout_xlsx, nts, **kws_wr)
917509
def process_xlsx(content):
    
    data = {}
    workbook = xlrd.open_workbook(file_contents=content)
    worksheets = [w for w in workbook.sheet_names() if not w.startswith('_')]
    for worksheet_name in worksheets:
        if worksheet_name.startswith('_'):
            continue

        worksheet = workbook.sheet_by_name(worksheet_name)

        merged_cells = worksheet.merged_cells
        if len(merged_cells):
            raise MergedCellError(worksheet.name, merged_cells)

        worksheet.name = slughifi(worksheet.name)
        headers = make_headers(worksheet)
        worksheet_data = make_worksheet_data(headers, worksheet)
        data[worksheet.name] = worksheet_data
    return data
275801
public void processSheet(
            StylesTable styles,
            ReadOnlySharedStringsTable strings,
            SheetContentsHandler sheetHandler,
            InputStream sheetInputStream) throws ReadExcelException {

        DataFormatter formatter = new DataFormatter();
        InputSource sheetSource = new InputSource(sheetInputStream);
        try {
            XMLReader sheetParser = SAXHelper.newXMLReader();
            ContentHandler handler = new XSSFSheetXMLHandlerPlus(
                    styles, null, strings, sheetHandler, formatter, false);
            sheetParser.setContentHandler(handler);
            //开始解析
            sheetParser.parse(sheetSource);
        } catch (ParserConfigurationException e) {
            throw new ReadExcelException("SAX parser appears to be broken - " + e.getMessage());
        } catch (Exception e) {
            throw new ReadExcelException(e.getMessage());
        }
    }
815554
private Optional<CellPosition> getHeaderPosition(final Sheet sheet, final XlsVerticalRecords anno,
            final FieldAccessor accessor, final Configuration config) throws AnnotationInvalidException, CellNotFoundException {

        if(Utils.isNotEmpty(anno.headerAddress())) {
            try {
                return Optional.of(CellPosition.of(anno.headerAddress()));

            } catch(IllegalArgumentException e) {
                throw new AnnotationInvalidException(anno, MessageBuilder.create("anno.attr.invalidAddress")
                        .var("property", accessor.getNameWithClass())
                        .varWithAnno("anno", XlsVerticalRecords.class)
                        .var("attrName", "headerAddress")
                        .var("attrValue", anno.headerAddress())
                        .format());

            }

        } else if(Utils.isNotEmpty(anno.tableLabel())) {
            try {
                final Cell labelCell = CellFinder.query(sheet, anno.tableLabel(), config).findWhenNotFoundException();

                if(anno.tableLabelAbove()) {
                    // 表の見出しが上にある場合、左側に補正する
                    int initColumn = labelCell.getColumnIndex() + anno.right()-1;
                    int initRow = labelCell.getRowIndex() + anno.bottom();
                    return Optional.of(CellPosition.of(initRow, initColumn));

                } else {

                    int initColumn = labelCell.getColumnIndex() + anno.right();
                    int initRow = labelCell.getRowIndex();
                    return Optional.of(CellPosition.of(initRow, initColumn));

                }

            } catch(CellNotFoundException ex) {
                if(anno.optional()) {
                    return Optional.empty();
                } else {
                    throw ex;
                }
            }
        } else {
            if(anno.headerRow() < 0) {
                throw  new AnnotationInvalidException(anno, MessageBuilder.create("anno.attr.min")
                        .var("property", accessor.getNameWithClass())
                        .varWithAnno("anno", XlsVerticalRecords.class)
                        .var("attrName", "headerRow")
                        .var("attrValue", anno.headerRow())
                        .var("min", 0)
                        .format());
            }

            if(anno.headerColumn() < 0) {
                throw new AnnotationInvalidException(anno, MessageBuilder.create("anno.attr.min")
                        .var("property", accessor.getNameWithClass())
                        .varWithAnno("anno", XlsVerticalRecords.class)
                        .var("attrName", "column")
                        .var("attrValue", anno.headerColumn())
                        .var("min", 0)
                        .format());

            }
            return Optional.of(CellPosition.of(anno.headerRow(), anno.headerColumn()));
        }
    }
1015722
def _read_xlsx_table(path):
    """"""
    workbook = pyxl.load_workbook(path)
    worksheet = workbook.active
    table = helpers.sheet_to_table(worksheet)

    return table
46425
def wr_xlsx(self, fout_xlsx, nts):
        """"""
        wr_xlsx(fout_xlsx, nts, prt_flds=self.prt_flds, fld2col_widths=self.fld2col_widths)
80597
def wr_xlsx(self, fout_xlsx):
        """"""
        objwr = WrXlsxSortedGos("GOEA", self.sortobj)
        #### fld2fmt['ratio_in_study'] = '{:>8}'
        #### fld2fmt['ratio_in_pop'] = '{:>12}'
        #### ntfld2wbfmtdict = {
        # ntfld_wbfmt = {
        #     'ratio_in_study': {'align':'right'},
        #     'ratio_in_pop':{'align':'right'}}
        kws_xlsx = {
            'title': self.ver_list,
            'fld2fmt': {f:'{:8.2e}' for f in self.flds_cur if f[:2] == 'p_'},
            #'ntfld_wbfmt': ntfld_wbfmt,
            #### 'ntval2wbfmtdict': ntval2wbfmtdict,
            #'hdrs': [],
            'prt_flds': self.flds_cur}
        objwr.wr_xlsx_nts(fout_xlsx, self.desc2nts, **kws_xlsx)
1036516
function wb_sheet_idx(wb, sh) {
	if(typeof sh == "number") {
		if(sh >= 0 && wb.SheetNames.length > sh) return sh;
		throw new Error("Cannot find sheet # " + sh);
	} else if(typeof sh == "string") {
		var idx = wb.SheetNames.indexOf(sh);
		if(idx > -1) return idx;
		throw new Error("Cannot find sheet name |" + sh + "|");
	} else throw new Error("Cannot find sheet |" + sh + "|");
}
519616
function(){
		this.list = {};

		/* 盤面表示設定 */
		this.add('font', 1, {option:[1,2]});					/* 文字の描画 1:ゴシック 2:明朝 */
		this.add('cursor', true);								/* カーソルの表示 */
		this.add('irowake', false);								/* 線の色分け */
		this.add('irowakeblk', false);							/* 黒マスの色分け */

		this.add('dispmove', true);								/* 線で動かすパズルで実際に動いたように描画 */
		this.add('disptype_yajilin',   1, {option:[1,2]});		/* yajilin: 表示形式 */
		this.add('disptype_pipelinkr', 1, {option:[1,2]});		/* pipelinkr: 表示形式 */
		this.add('disptype_bosanowa',  1, {option:[1,2,3]});	/* bosanowa: 表示形式 */
		this.add('snakebd', false);								/* hebi: へびの境界線を表示する */
		this.add('dispqnumbg', false);							/* yinyang: 問題のまるに背景色をつける */
		this.add('undefcell', true);							/* shugaku: 未確定マスはグレー表示にする */

		this.add('squarecell', true);							/* セルは正方形にする */

		/* 表示色の設定 */
		this.add('color_shadecolor', "");						/* 黒マスの表示色の表示 */
		this.add('color_bgcolor', "white");						/* 背景色の設定 */

		/* 入力方法設定 */
		this.add('use', (!pzpr.env.API.touchevent?1:2), {option:[1,2]});	/* 黒マスの入力方法 */
		this.add('use_tri', 1, {option:[1,2,3]});				/* shakashaka: 三角形の入力方法 */

		this.add('bgcolor', false);			/* slither 背景色入力 */
		this.add('singlenum', (!pzpr.env.API.touchevent));	/* hanare: 部屋に回答数字を一つだけ入力 */
		this.add('enline', true);			/* kouchoku: 線は点の間のみ引ける */
		this.add('lattice', true);			/* kouchoku: 格子点チェック */

		/* 回答お助け機能 */
		this.add('autocmp', true,  {variety:true});	/* 数字 or kouchokuの正解の点をグレーにする */
		this.add('autoerr', false, {variety:true});	/* hitori:ひとくれの重複した数字を表示, gokigen,wagiri:斜線の色分け */

		/* 正解判定 */
		this.add('multierr', false);		/* エラー判定で複数エラーを出力する */
		this.add('allowempty', false);		/* 盤面に線や黒マスがなくても正解と判定する */
		this.add('forceallcell', false);	/* fillomino: すべての数字が入っている時のみ正解とする */
		this.add('passallcell', true);		/* arukone: すべてのセルに線が通っている時のみ正解とする */

		/* EDITORのみ */
		this.add('bdpadding', true);		/* goishi: URL出力で1マス余裕を持って出力する */
		this.add('discolor', false);		/* tentaisho: 色分け無効化 */

		/* その他の特殊項目(保存なし) */
		this.add('uramashu', false, {volatile:true});		/* 裏ましゅにする */
	}
373459
protected void init() {

        // 読み込み用の登録
        registerForReading(conversionHandler);
        registerForReading(new ParseProcessorFactory<>());
        registerForReading(constraintHandler);

        // 書き込み用の登録
        registerForWriting(constraintHandler);
        registerForWriting(new PrintProcessorFactory<>());
        registerForWriting(conversionHandler);

        // 変換用の登録
        registerForConversion(CsvNullConvert.class, new NullConvertFactory());
        registerForConversion(CsvDefaultValue.class, new DefaultValueFactory());
        registerForConversion(CsvTrim.class, new TrimFactory());
        registerForConversion(CsvUpper.class, new UpperFactory());
        registerForConversion(CsvLower.class, new LowerFactory());
        registerForConversion(CsvRegexReplace.class, new RegexReplaceFactory());
        registerForConversion(CsvWordReplace.class, new WordReplaceFactory());
        registerForConversion(CsvFullChar.class, new FullCharFactory());
        registerForConversion(CsvHalfChar.class, new HalfCharFactory());
        registerForConversion(CsvLeftPad.class, new LeftPadFactory());
        registerForConversion(CsvRightPad.class, new RightPadFactory());
        registerForConversion(CsvMultiPad.class, new MultiPadFactory());
        registerForConversion(CsvOneSideTrim.class, new OneSideTrimFactory());

        // 制約用の登録
        registerForConstraint(CsvRequire.class, new RequireFactory());
        registerForConstraint(CsvUnique.class, new UniqueFactory<>());
        registerForConstraint(CsvUniqueHashCode.class, new UniqueHashCodeFactory<>());
        registerForConstraint(CsvEquals.class, new EqualsFactory<>());

    }
1104576
protected CellFormulaHandler createCellFormulaHandler(final XlsFormula formulaAnno, final FieldAccessor field, final Configuration config) {

        if(!formulaAnno.value().isEmpty()) {
            final String formulaExpression = formulaAnno.value();
            try {
                // EL式として正しいか検証する
                config.getFormulaFormatter().interpolate(formulaExpression, Collections.emptyMap());

            } catch(ExpressionEvaluationException e) {
                throw new AnnotationInvalidException(formulaAnno, MessageBuilder.create("anno.attr.invalidEL")
                        .var("property", field.getNameWithClass())
                        .varWithAnno("anno", XlsFormula.class)
                        .var("attrName", "value")
                        .var("attrValue", formulaExpression)
                        .format());
            }

            CellFormulaHandler handler = new CellFormulaHandler(formulaExpression);
            handler.setPrimaryFormula(formulaAnno.primary());
            return handler;

        } else if(!formulaAnno.methodName().isEmpty()) {
            // 戻り値が文字列の数式を返すメソッドを探す
            final Class<?> targetClass = field.getDeclaringClass();
            Method method = null;
            for(Method m : targetClass.getDeclaredMethods()) {
                if(m.getName().equals(formulaAnno.methodName())
                        && m.getReturnType().equals(String.class)) {
                    method = m;
                    break;
                }
            }

            if(method == null) {
                throw new AnnotationInvalidException(formulaAnno, MessageBuilder.create("anno.attr.notFoundMethod")
                        .var("property", field.getNameWithClass())
                        .varWithAnno("anno", XlsFormula.class)
                        .var("attrName", "methodName")
                        .var("attrValue", formulaAnno.methodName())
                        .varWithClass("definedClass", targetClass)
                        .format());
            }

            method.setAccessible(true);
            CellFormulaHandler handler = new CellFormulaHandler(method);
            handler.setPrimaryFormula(formulaAnno.primary());
            return handler;

        } else {
            throw new AnnotationInvalidException(formulaAnno, MessageBuilder.create("anno.attr.required.any")
                    .var("property", field.getNameWithClass())
                    .varWithAnno("anno", XlsFormula.class)
                    .varWithArrays("attrNames", "value", "methodName")
                    .format());
        }

    }