[转] Make an Excel format report with Java

xiaoxiao2021-03-05  20

try {getDBConnection (); pstmt = conn.prepareStatement (strSql); ret = pstmt.executeQuery (); File tempFile = new File (filename); try {WritableWorkbook workbook = Workbook.createWorkbook (tempFile); WritableSheet sheet = workbook.createSheet ("Sheet1", 0); Label L = NULL; JXL.WRITE.NUMBER N = NULL; JXL.WRITE.DATETIME D = NULL; WritableFont Headerfont = New WritableFont (Writablefont.arial, 12, Writablefont.Bold, False, underlinestyle .No_underline, jxl.format.colour.blue; WritablecellFormat Headerformat = New WritablecellFormat (Headerfont);

WritableFont titleFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.RED); WritableCellFormat titleFormat = new WritableCellFormat (titleFont);

WritableFont detFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK); WritableCellFormat detFormat = new WritableCellFormat (detFont);

Numberformat NF = New NumberFormat ("0.00000"); WritablecellFormat PriceFormat = New WritablecellFormat (Detfont, NF);

DateFormat DF = New DateFormat ("YYYY-MM-DD"); WritableCellFormat DateFormat = New WritablecellFormat (Detfont, DF);

L = New label (2, 0, "", HeaderFormat; Sheet.Addcell (L); int intel = Title.length; for (int i = 0; i

WritableFont titleFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.RED); WritableCellFormat titleFormat = new WritableCellFormat (titleFont); WritableFont detFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.no_Bold, False, underlinestyle.no_underline, jxl.format.colour.black; WritablecellFormat Detformat = New WritablecellFormat (DETFONT);

Numberformat NF = New NumberFormat ("0.00000"); WritablecellFormat PriceFormat = New WritablecellFormat (Detfont, NF);

DateFormat DF = New DateFormat ("YYYY-MM-DD"); WritableCellFormat DateFormat = New WritablecellFormat (Detfont, DF);

L = New label (2, 0, "", HeaderFormat; Sheet.Addcell (L); int intel = Title.length; for (int i = 0; i

WritableFont titleFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.RED); WritableCellFormat titleFormat = new WritableCellFormat (titleFont); WritableFont detFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.no_Bold, False, underlinestyle.no_underline, jxl.format.colour.black; WritablecellFormat Detformat = New WritablecellFormat (DETFONT);

Numberformat NF = New NumberFormat ("0.00000"); WritablecellFormat PriceFormat = New WritablecellFormat (Detfont, NF);

DateFormat DF = New DateFormat ("YYYY-MM-DD"); WritableCellFormat DateFormat = New WritablecellFormat (Detfont, DF);

L = New label (2, 0, "", HeaderFormat; Sheet.Addcell (L); int intel = Title.length; for (int i = 0; i

WritableFont titleFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.RED); WritableCellFormat titleFormat = new WritableCellFormat (titleFont); WritableFont detFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.no_Bold, False, underlinestyle.no_underline, jxl.format.colour.black; WritablecellFormat Detformat = New WritablecellFormat (DETFONT);

Numberformat NF = New NumberFormat ("0.00000"); WritablecellFormat PriceFormat = New WritablecellFormat (Detfont, NF);

DateFormat DF = New DateFormat ("YYYY-MM-DD"); WritableCellFormat DateFormat = New WritablecellFormat (Detfont, DF);

L = New label (2, 0, "", HeaderFormat; Sheet.Addcell (L); int intel = Title.length; for (int i = 0; i

WritableFont titleFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.RED); WritableCellFormat titleFormat = new WritableCellFormat (titleFont); WritableFont detFont = new WritableFont (WritableFont.ARIAL, 10, WritableFont.no_Bold, False, underlinestyle.no_underline, jxl.format.colour.black; WritablecellFormat Detformat = New WritablecellFormat (DETFONT);

Numberformat NF = New NumberFormat ("0.00000"); WritablecellFormat PriceFormat = New WritablecellFormat (Detfont, NF);

DateFormat DF = New DateFormat ("YYYY-MM-DD"); WritableCellFormat DateFormat = New WritablecellFormat (Detfont, DF);

转载请注明原文地址:https://www.9cbs.com/read-38843.html

New Post(0)