jxl 實現excel動態水印

2021-08-08 20:38:07 字數 1362 閱讀 8491

static int width=300;

static int height=50;

public static map createwatermark1(map watermarkmessage) throws ioexception   

}graphics2d g2d = bi.creategraphics();

// 設定字型顏色為灰色   

g2d.setcolor(color.light_gray);   

// 設定的屬性      

g2d.setstroke(new basicstroke(1));    

// 設定字型   

g2d.setfont(new font("serif", font.italic, 40));

// 設定字型傾斜度  

g2d.rotate(math.toradians(-8)); 

// 寫入水印文字原定高度過小,所以累計寫水印,增加高度   

g2d.drawstring("匯出時間 :  " + watermarkmessage.get("time"), 0, 180 + 40 * (1+ 2)); 

g2d.drawstring("匯出工號 :  " + watermarkmessage.get("loginname"),0,180 + 40 * (1+3)); 

g2d.drawstring("工號部門 :  " + watermarkmessage.get("domain"), 0,180 + 40 * (1+ 4)); 

// 設定透明度   

g2d.setcomposite(alphacomposite.getinstance(alphacomposite.src_over));

// 釋放物件   

g2d.dispose(); 

// 通過bmp寫入檔案  

// bmpencoder.write(bi, file);   

imageio.write(bi, "bmp", file);

map.put("file", file);    

map.put("width", width);   

map.put("height", height);    

return map; 

}public static map tomap(string jsonstring) throws jsonexception

return result;   

} public static void addwatermark(string xls_filepath_in,string xls_filepath_out,jsonobject watermarktext) throws exception

JXL實現excel匯出案例(分sheet頁)

原來專案中也是有匯出的方法,自己覺得不太滿意,就自己重新寫了乙個公用方法。這種類似的方法很多,這裡只是自己的乙個案例。對於匯出,應該有的引數是 要匯出的字段 資料列表以 excel的表頭及檔名。這裡主要實現了分sheet頁匯出。先看看 吧 action中確定了匯出的引數及查詢好了資料列表,直接呼叫e...

JXL獲取excel批註

不知道為什麼,竟然google上竟然都搜不到jxl獲取excel批註的方法,只能自己去看api,然後寫了個最簡單的測試 我用了jxl最新的2.6.12版本,竟然還不支援office的xlsx格式 jxl.jar 2.6.12 author lmiky date 2011 11 26 public c...

jxl 匯入 excel 檔案

前提要做的 匯入jxl包 1.首先要把上傳的文個件上傳到伺服器上.並得到檔案的絕對路徑 2.new乙個新的檔案物件出來,並得到輸入流 file file new file 檔案路徑 通過這個檔案物件得到檔案輸入流 fileinputstream fis new fileinputstream fil...