將自己公司OA系統的通訊錄導入到微信企業號,可以節省很多的時間。
在批量導入頁面,你可以下載標准模板
手工填寫?no. 開發人員寫一個小程序便可生成符合格式的Excel文件。
【注意】文件必須有表頭,表頭內容必須和模板一致,即“姓名”,"賬號“,輸錯可不行哦。
部門格式:一級部門/二級部門/三級部門
各級部門用斜杠分隔,同屬於多個部門的用分號分隔,如 騰訊公司/微信事業群/企業產品部;騰訊公司/社交事業群/社交媒體產品部,表示
該同事同屬於企業產品部和社交媒體產品部。
當組織架構無此部門,則會自動創建部門。
以下為生成標准文件的一段小程序:
1 /** 2 * 生成微信企業號批量導入用的表格xlsx -- http://www.leegtang.com 3 * @param pb 4 */ 5 public void writeXls(PageBean pb){ 6 try { 7 Workbook wb = new XSSFWorkbook(); 8 CreationHelper createHelper = wb.getCreationHelper(); 9 Sheet sheet = wb.createSheet("通訊錄wechat-Qy"); 10 // Create a row and put some cells in it. Rows are 0 based. 11 12 13 // --------- 必須設置表頭,否則企業號導入服務無法識別,表頭名稱必須正確無誤 ------------- 14 // ---------- 導入后需要重新登錄,新加的部門才可見 ,這好像是個bug ----------------- 15 Row row = sheet.createRow((short)0); 16 // Create a cell and put a value in it. 17 row.createCell(0).setCellValue("姓名"); 18 row.createCell(1).setCellValue("賬號"); 19 row.createCell(2).setCellValue("性別"); 20 row.createCell(3).setCellValue("微信號"); 21 row.createCell(4).setCellValue("手機號"); 22 row.createCell(5).setCellValue("郵箱"); 23 row.createCell(6).setCellValue("所屬部門"); 24 row.createCell(7).setCellValue("職位"); 25 26 List lst=pb.getData(); 27 int i=1; 28 for (Iterator iterator = lst.iterator(); iterator.hasNext();) { 29 DingUser object = (DingUser) iterator.next(); 30 System.out.println(object); 31 32 Row row_ = sheet.createRow((short)i); 33 // Create a cell and put a value in it. 34 row_.createCell(0).setCellValue(object.getName()); 35 row_.createCell(1).setCellValue(getPingYin(object.getName())); 36 row_.createCell(2).setCellValue(object.getSex()); 37 row_.createCell(3).setCellValue(""); 38 row_.createCell(4).setCellValue(createHelper.createRichTextString(object.getTel())); 39 row_.createCell(5).setCellValue(""); 40 row_.createCell(6).setCellValue("B.Team/"+object.getDept()); // B.Team為 最頂級的部門名稱,其他部門都在此部門下 41 row_.createCell(7).setCellValue(object.getTitle()); 42 43 44 i++; 45 } 46 47 48 String filePath="F:/adoc/wechat-qy.xlsx"; 49 FileOutputStream fileOut = new FileOutputStream(filePath); 50 wb.write(fileOut); 51 fileOut.close(); 52 System.out.println("########################"); 53 System.out.println(filePath+"寫入成功!"); 54 } catch (Exception e) { 55 e.printStackTrace(); 56 } 57 }
更多內容,請到 http://www.leegtang.com