POI org.apache.poi.hssf.usermodel HSSFWorkbook getSheetName(int sheetIndex)
Description Of HSSFWorkbook: getSheetName(int sheetIndex)
The java.lang.HSSFWorkbook.getSheetName(int sheetIndex) Get the sheet nameHSSFWorkbook.getSheetName(int sheetIndex) method return string name of sheet
Code Example Java HSSFWorkbook
ตัวอย่างโค้ด
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; public class PoiExam { public static void main(String[] args) { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet1 = workbook.createSheet("sheetname 1"); HSSFSheet sheet2 = workbook.createSheet("sheetname 2"); System.out.println("sheet1 is name : " + workbook.getSheetName(0)); System.out.println("sheet2 is name : " + workbook.getSheetName(1)); FileOutputStream fos = null; try { fos = new FileOutputStream(new File("PoiExam.xls")); workbook.write(fos); System.out.println("SUCCESS"); } catch (IOException e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.flush(); fos.close(); } catch (IOException e) { e.printStackTrace(); } } } } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น