Save Excel
Apache POI 라이브러리를 사용하여 SBGrid를 Excel 파일로 저장합니다.
요약
SBGrid에서 saveExcel 기능을 제공합니다.입력값
String : Save File Name
String : 변환 모듈
예) datagrid1.saveExcelEx("savedExcelFile", "http://www.sbgrid.co.kr/saveExcelExManager", true);
상세설명
BGrid로 로드 된 데이터들을 Excel파일 형태로 저장가능 합니다.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <html xmlns="http://www.w3.org/1999/xhtml" lang="ko"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" /> <title> SB Grid </title> <link href="/kr/co/softbowl/css/Sbgrid_default.css" type="text/css" rel="stylesheet" /> <link href="/css/sort.css" type="text/css" rel="stylesheet" /> <jsp:include page="/view/common/cmCommon.jsp"/> <script type="text/javascript" src="/kr/co/softbowl/SBGrid.js"></script> <script type="text/javascript" src="/js/jsondata/DATA_JSON_eval2.js"></script> <style type="text/css"> table{border:0px solid #d6d6d6 !important;} table th{border:0px solid #d6d6d6 !important;} table td{border:0px solid #d6d6d6 !important; } </style> <script type="text/javascript"> SBGrid.DEF.DOMAIN = "../../"; var datagrid1, datagrid2, firstRowHeight = 30; $(document).ready(function () { __createElements(); }); function __createElements() { var GridInitInfo = { "strParentId": "sbGridArea", "strId": "datagrid1", "strCaption": "주문번호^배송번호^이름^주민번호^전화번호^금액", "strColWidth": "120, 150, 150, 150, 120, 200", "strJsonRef": "eval1.grid", "strDataHeight": "29", "strBackColorAlternate": "#f7f7f7", "strStyle": "width:100%; height:480px;" }; var SBGridColumnInitInfo = [ { "id": "col1", "type": "output", "ref": "orderdate", "style": "text-align:center" }, { "id": "col2", "type": "output", "ref": "deliverynum", "style": "text-align:center" }, { "id": "col3", "type": "output", "ref": "name", "style": "text-align:center" }, { "id": "col4", "type": "output", "ref": "identification", "style": "text-align:center" }, { "id": "col5", "type": "output", "ref": "phone", "style": "text-align:center" }, { "id": "col6", "type": "output", "ref": "price", "style": "text-align:right;padding:5px" } ]; SBGridColumnInitInfo[0].format = "yyyy-mm-dd"; SBGridColumnInitInfo[1].format = "L99-LL999"; SBGridColumnInitInfo[3].format = "999999-9999999"; SBGridColumnInitInfo[4].format = "99-999-9999"; SBGridColumnInitInfo[5].format = "#,###"; datagrid1 = createSBGrid(GridInitInfo, SBGridColumnInitInfo); datagrid1.setRowHeight(0, 30); }; function datagridSaveExcel() { var actionUrl = '/saveExcelExManager'; objExcelInfo = { "strFileName" : "exportExcel.xlsx", "strAction" : actionUrl, "arrNumberTypeCols" : [5], "objTitleInfo" : [ { "title" : "첫 번째 제목 줄", "style" : { "background-color" : "rgb (255, 255, 0)" }, "height" : 100 } ] //"bIsMerge" : true, //default는 false //"bIsStyle" : true, //default는 false //"bUseFormat" : true, //default는 false //"bIncludeData" : true, //default는 true //"bAutoResize" : false, //default는 false //"arrAutoResizeCols" : [2, 7], //"arrRemoveCols" : [4,5,8], //"arrMergeCancelCols" : [3,4], //해당 컬럼들의 병합을 수행하지 않음 //"arrMergeCancleRows" : [6,65], //해당 행들의 병합을 수행하지 않음 }; datagrid1.exportExcel(objExcelInfo); }; function createSBGrid(SBGridInitInfo, SBGridColumnInitInfo) { var objJSONdata = new Object(); objJSONdata.objSBGridInitInfo = SBGridInitInfo; objJSONdata.arSBGridColumnInitInfo = SBGridColumnInitInfo; return SBGrid.DEF.createSBGrid(objJSONdata); }; </script> </head> <body> <div id="button_group"> <input type="button" class="sbgrid_demo_button2" style="width:33%; height:30px; background-color:#F2CB61;" ivalue="SBGrid -> Excel 파일로 저장" /> </div> <div id="sbGridArea"></div> </body> </html>