- 浏览: 308052 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
ae6623:
ae6623 写道大哥,你是怎么知道它对临时文件有限制的,我也 ...
导出excel2007 poi3.8 -
ae6623:
大哥,你是怎么知道它对临时文件有限制的,我也发现这个bug了, ...
导出excel2007 poi3.8 -
coralandbill:
下载不了啊 能不能给我发一个simpleProj.war包啊 ...
jqgrid使用步骤及说明 -
maojin:
这是jqgrid几?那个电话号码校验的函数能调到吗?
jqgrid使用步骤及说明 -
qingyezhu:
请问,用poi3.8中的wordtohtmlconver类将d ...
导出excel2007 poi3.8
package sina.hive.vipfaninfo;
import java.io.File;
import java.util.Iterator;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.HTablePool;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.log4j.Logger;
import sina.hive.init.EffectInit;
public class FanExcel {
private Logger log = Logger.getLogger(FanExcel.class);
private HTablePool hTablePool;
private static final String TABLE_NAME = "temp_sina_analyzer";
private static final String PATH = "/home/hdfs/effect/liubx/tempFan.xls";
private static final String TEMPLATE_PATH = "/home/hdfs/effect/liubx/template.xls";
private static FanExcel fanExcel = new FanExcel();
private WritableWorkbook wokbook = null;
private int one_index = 0;
private int two_index = 0;
private int three_index = 0;
private int four_index = 0;
private int five_index = 0;
private int six_index = 0;
private int seven_index = 0;
private WritableSheet oneSheet;
private WritableSheet twoSheet;
private WritableSheet threeSheet;
private WritableSheet fourSheet;
private WritableSheet fiveSheet;
private WritableSheet sixSheet;
private WritableSheet sevenSheet;
private Label label = null;
private jxl.write.Number numberCell = null;
private byte[] family = "baseInfo".getBytes();
String arry1[] = null;
String arry2[] = null;
String fan_str = null;
byte tmp[] = null;
public static FanExcel getFanExcel() {
if (fanExcel == null) {
fanExcel = new FanExcel();
}
return fanExcel;
}
private FanExcel() {
init(true);
}
public HTable getHtable(String tableName) {
if (hTablePool != null) {
return (HTable) hTablePool.getTable(tableName);
} else {
Configuration configuration = HBaseConfiguration.create();
configuration.set("hbase.master", EffectInit.hbaseMaster);
configuration.set("hbase.zookeeper.quorum",
EffectInit.hbaseZkQuorum);
configuration.set("hbase.zookeeper.property.clientPort",
EffectInit.hbaseZkClientPort);
configuration.get("hbase.master");
hTablePool = new HTablePool(configuration,
EffectInit.hbasePoolMaxSize);
return (HTable) hTablePool.getTable(tableName);
}
}
private void init(boolean isFirst) {
File file = new File(FanExcel.PATH);
log.info("开始初始化EXCEL信息:");
Workbook wb = null;
try {
// Excel模板
if(isFirst){
wb = Workbook.getWorkbook(new File(FanExcel.TEMPLATE_PATH));
}else{
wb = Workbook.getWorkbook(new File(FanExcel.PATH));
}
this.wokbook = Workbook.createWorkbook(file, wb);
this.oneSheet = this.wokbook.getSheet(0);
this.twoSheet = this.wokbook.getSheet(1);
this.threeSheet = this.wokbook.getSheet(2);
this.fourSheet = this.wokbook.getSheet(3);
this.fiveSheet = this.wokbook.getSheet(4);
this.sixSheet = this.wokbook.getSheet(5);
this.sevenSheet = this.wokbook.getSheet(6);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
log.info("结束初始化EXCEL信息!");
}
/**
* 微博基本信息页
*/
private void oneSheet(Result rs) throws Exception {
this.one_index++;
label = new Label(0, one_index, new String(rs.getRow(), "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "nickName".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(1, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "gender".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(2, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "address".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(3, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(4, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "attentCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(5, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(6, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "favCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(7, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "description".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(8, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "createdTime".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(9, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "activeDegree".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(10, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "isVip".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(11, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "isCorpseFan".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(12, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "recentFdCount200".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(13, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "recentCmCount200".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(14, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "oriRate200".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(15, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "forwardRate200".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(16, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lWbCount90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(17, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lByFwdCounts90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(18, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lByCmtCounts90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(19, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "l1ByFCCount90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(20, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lAvgByFCCount90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(21, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lAvgWbCount90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(22, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lWbCount30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(23, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lByFwdCounts30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(24, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lByCmtCounts30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(25, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "l1ByFCCount30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(26, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lAvgByFCCount30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(27, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lAvgWbCount30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(28, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
/*
* 生成一个保存数字的单元格 必须使用Number的完整包路径,否则有语法歧义 单元格位置是第二列,第一行,值为789.123
*/
// jxl.write.Number number = new jxl.write.Number(1, 0, 555.12541);
// sheet.addCell(number);
}
/**
* 近90天用户指数
*/
private void twoSheet(Result rs) throws Exception {
this.two_index++;
label = new Label(0, two_index, new String(rs.getRow(), "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "nickName".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(1, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "address".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(2, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "netEffectIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(3, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanEffectIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(4, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanCountIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(5, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanQualityIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(6, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboEffectIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(7, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "bowenCountIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(8, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "bowenQualityIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(9, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboInteractIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(10, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanJoinIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(11, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "interactTrendIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(12, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
}
/**
* 近30天用户指数
*/
public void threeSheet(Result rs) throws Exception {
this.three_index++;
label = new Label(0, this.three_index, new String(rs.getRow(), "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "nickName".getBytes());
if (tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(1, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "address".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(2, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "netEffectIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(3, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanEffectIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(4, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanCountIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(5, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanQualityIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(6, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboEffectIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(7, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "bowenCountIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(8, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "bowenQualityIndex30".getBytes());
if (tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(9, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboInteractIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(10, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanJoinIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(11, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "interactTrendIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(12, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
}
/**
* 粉丝性别&质量
*/
public void foursheet(Result rs) throws Exception {
this.four_index++;
label = new Label(0, this.four_index, new String(rs.getRow(), "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "nickName".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(1, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "address".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(2, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lMFansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(3, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lWFansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(4, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lVFansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(5, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lCorpseFansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(6, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lGrassRootsFan".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(7, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
}
/**
* 二级粉丝区间分布
*/
public void fivesheet(Result rs) throws Exception {
this.tmp = rs.getValue(this.family, "fan2fenbu".getBytes());
if (this.tmp == null) {
return;
}
fan_str = new String(this.tmp, "utf-8");
if (fan_str == null || fan_str.indexOf("|") <= 0) {
return;
}
arry1 = fan_str.split(" ");
for (String str : arry1) {
this.five_index++;
arry2 = str.split("\\|");
label = new Label(0, this.five_index, new String(rs.getRow(),
"utf-8"));
this.fiveSheet.addCell(label);
label = new Label(1, this.five_index, new String(rs.getValue(
this.family, "nickName".getBytes()), "utf-8"));
this.fiveSheet.addCell(label);
label = new Label(2, this.five_index, new String(rs.getValue(
this.family, "address".getBytes()), "utf-8"));
this.fiveSheet.addCell(label);
label = new Label(5, this.five_index, arry2[1]);
this.fiveSheet.addCell(label);
arry2 = arry2[0].split("_");
label = new Label(3, this.five_index, arry2[0]);
this.fiveSheet.addCell(label);
if(arry2.length<2){
label = new Label(4, this.five_index, "-1");
}else{
label = new Label(4, this.five_index, arry2[1]);
}
this.fiveSheet.addCell(label);
}
}
/**
* 粉丝地域分布
*/
public void sixsheet(Result rs) throws Exception {
this.tmp = rs.getValue(this.family, "diyufenbu".getBytes());
if (tmp == null) {
return;
}
this.fan_str = new String(this.tmp, "utf-8");
if (this.fan_str == null || this.fan_str.indexOf("|") <= 0) {
return;
}
this.arry1 = this.fan_str.split(" ");
for (String str : arry1) {
this.six_index++;
arry2 = str.split("\\|");
label = new Label(0, this.six_index, new String(rs.getRow(),
"utf-8"));
this.sixSheet.addCell(label);
label = new Label(1, this.six_index, new String(rs.getValue(
this.family, "nickName".getBytes()), "utf-8"));
this.sixSheet.addCell(label);
label = new Label(2, this.six_index, new String(rs.getValue(
this.family, "address".getBytes()), "utf-8"));
this.sixSheet.addCell(label);
label = new Label(3, this.six_index, arry2[0]);
this.sixSheet.addCell(label);
label = new Label(4, this.six_index, arry2[1]);
this.sixSheet.addCell(label);
}
}
/**
* 粉丝活跃度分布
*/
public void sevensheet(Result rs) throws Exception {
this.tmp = rs.getValue(this.family, "daywbfenbu".getBytes());
if (this.tmp == null) {
return;
}
this.fan_str = new String(this.tmp, "utf-8");
if (this.fan_str == null || this.fan_str.indexOf("|") <= 0) {
return;
}
this.arry1 = this.fan_str.split(" ");
for (String str : arry1) {
this.seven_index++;
arry2 = str.split("\\|");
label = new Label(0, this.seven_index, new String(rs.getRow(),
"utf-8"));
this.sevenSheet.addCell(label);
label = new Label(1, this.seven_index, new String(rs.getValue(
this.family, "nickName".getBytes()), "utf-8"));
this.sevenSheet.addCell(label);
label = new Label(2, this.seven_index, new String(rs.getValue(
this.family, "address".getBytes()), "utf-8"));
this.sevenSheet.addCell(label);
label = new Label(5, this.seven_index, arry2[1]);
this.sevenSheet.addCell(label);
arry2 = arry2[0].split("_");
label = new Label(3, this.seven_index, arry2[0]);
this.sevenSheet.addCell(label);
if(arry2.length<2){
label = new Label(4, this.seven_index, "-1");
}else{
label = new Label(4, this.seven_index, arry2[1]);
}
this.sevenSheet.addCell(label);
}
}
private void closeExcel() {
try {
if (this.wokbook != null) {
this.wokbook.write();
this.wokbook.close();
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
}
public void exportExcel() {
HTable htable = getHtable(FanExcel.TABLE_NAME);
Scan scan = new Scan();
Result rs = null;
int n =0;
int n2=0;
try {
ResultScanner rscan = htable.getScanner(scan);
Iterator<Result> it = rscan.iterator();
while (it.hasNext()) {
rs = it.next();
if (rs == null || rs.isEmpty()) {
continue;
}
this.oneSheet(rs);
this.twoSheet(rs);
this.threeSheet(rs);
this.foursheet(rs);
this.fivesheet(rs);
this.sixsheet(rs);
this.sevensheet(rs);
n2++;
n++;
if(n==500){
System.out.println("重新初始化操作!");
this.closeExcel();
this.init(false);
}
}
} catch (Exception ex) {
log.error(new String(rs.getRow()));
log.error(ex.getMessage(), ex);
} finally {
System.out.println("写入记录数:"+n2);
System.out.println("sheet1:"+this.one_index);
System.out.println("sheet2:"+this.two_index);
System.out.println("sheet3:"+this.three_index);
System.out.println("sheet4:"+this.four_index);
System.out.println("sheet5:"+this.five_index);
System.out.println("sheet6:"+this.six_index);
System.out.println("sheet7:"+this.seven_index);
closeExcel();
}
}
public static void main(String arg[]) {
FanExcel fanexcel = FanExcel.getFanExcel();
System.out.println("开始导出excel数据:");
fanexcel.exportExcel();
System.out.println("结束导出excel数据:");
}
}
import java.io.File;
import java.util.Iterator;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.HTablePool;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.log4j.Logger;
import sina.hive.init.EffectInit;
public class FanExcel {
private Logger log = Logger.getLogger(FanExcel.class);
private HTablePool hTablePool;
private static final String TABLE_NAME = "temp_sina_analyzer";
private static final String PATH = "/home/hdfs/effect/liubx/tempFan.xls";
private static final String TEMPLATE_PATH = "/home/hdfs/effect/liubx/template.xls";
private static FanExcel fanExcel = new FanExcel();
private WritableWorkbook wokbook = null;
private int one_index = 0;
private int two_index = 0;
private int three_index = 0;
private int four_index = 0;
private int five_index = 0;
private int six_index = 0;
private int seven_index = 0;
private WritableSheet oneSheet;
private WritableSheet twoSheet;
private WritableSheet threeSheet;
private WritableSheet fourSheet;
private WritableSheet fiveSheet;
private WritableSheet sixSheet;
private WritableSheet sevenSheet;
private Label label = null;
private jxl.write.Number numberCell = null;
private byte[] family = "baseInfo".getBytes();
String arry1[] = null;
String arry2[] = null;
String fan_str = null;
byte tmp[] = null;
public static FanExcel getFanExcel() {
if (fanExcel == null) {
fanExcel = new FanExcel();
}
return fanExcel;
}
private FanExcel() {
init(true);
}
public HTable getHtable(String tableName) {
if (hTablePool != null) {
return (HTable) hTablePool.getTable(tableName);
} else {
Configuration configuration = HBaseConfiguration.create();
configuration.set("hbase.master", EffectInit.hbaseMaster);
configuration.set("hbase.zookeeper.quorum",
EffectInit.hbaseZkQuorum);
configuration.set("hbase.zookeeper.property.clientPort",
EffectInit.hbaseZkClientPort);
configuration.get("hbase.master");
hTablePool = new HTablePool(configuration,
EffectInit.hbasePoolMaxSize);
return (HTable) hTablePool.getTable(tableName);
}
}
private void init(boolean isFirst) {
File file = new File(FanExcel.PATH);
log.info("开始初始化EXCEL信息:");
Workbook wb = null;
try {
// Excel模板
if(isFirst){
wb = Workbook.getWorkbook(new File(FanExcel.TEMPLATE_PATH));
}else{
wb = Workbook.getWorkbook(new File(FanExcel.PATH));
}
this.wokbook = Workbook.createWorkbook(file, wb);
this.oneSheet = this.wokbook.getSheet(0);
this.twoSheet = this.wokbook.getSheet(1);
this.threeSheet = this.wokbook.getSheet(2);
this.fourSheet = this.wokbook.getSheet(3);
this.fiveSheet = this.wokbook.getSheet(4);
this.sixSheet = this.wokbook.getSheet(5);
this.sevenSheet = this.wokbook.getSheet(6);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
log.info("结束初始化EXCEL信息!");
}
/**
* 微博基本信息页
*/
private void oneSheet(Result rs) throws Exception {
this.one_index++;
label = new Label(0, one_index, new String(rs.getRow(), "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "nickName".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(1, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "gender".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(2, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "address".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(3, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(4, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "attentCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(5, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(6, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "favCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(7, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "description".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(8, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "createdTime".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(9, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "activeDegree".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(10, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "isVip".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(11, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "isCorpseFan".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(12, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "recentFdCount200".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(13, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "recentCmCount200".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(14, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "oriRate200".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(15, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "forwardRate200".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(16, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lWbCount90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(17, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lByFwdCounts90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(18, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lByCmtCounts90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(19, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "l1ByFCCount90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(20, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lAvgByFCCount90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(21, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lAvgWbCount90".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(22, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lWbCount30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(23, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lByFwdCounts30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(24, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lByCmtCounts30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(25, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "l1ByFCCount30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(26, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lAvgByFCCount30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(27, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lAvgWbCount30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(28, one_index, new String(this.tmp, "utf-8"));
this.oneSheet.addCell(label);
/*
* 生成一个保存数字的单元格 必须使用Number的完整包路径,否则有语法歧义 单元格位置是第二列,第一行,值为789.123
*/
// jxl.write.Number number = new jxl.write.Number(1, 0, 555.12541);
// sheet.addCell(number);
}
/**
* 近90天用户指数
*/
private void twoSheet(Result rs) throws Exception {
this.two_index++;
label = new Label(0, two_index, new String(rs.getRow(), "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "nickName".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(1, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "address".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(2, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "netEffectIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(3, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanEffectIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(4, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanCountIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(5, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanQualityIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(6, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboEffectIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(7, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "bowenCountIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(8, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "bowenQualityIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(9, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboInteractIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(10, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanJoinIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(11, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
this.tmp = rs.getValue(this.family, "interactTrendIndex".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(12, two_index, new String(this.tmp, "utf-8"));
this.twoSheet.addCell(label);
}
/**
* 近30天用户指数
*/
public void threeSheet(Result rs) throws Exception {
this.three_index++;
label = new Label(0, this.three_index, new String(rs.getRow(), "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "nickName".getBytes());
if (tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(1, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "address".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(2, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "netEffectIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(3, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanEffectIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(4, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanCountIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(5, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanQualityIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(6, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboEffectIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(7, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "bowenCountIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(8, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "bowenQualityIndex30".getBytes());
if (tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(9, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "weiboInteractIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(10, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "fanJoinIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(11, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
this.tmp = rs.getValue(this.family, "interactTrendIndex30".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(12, this.three_index, new String(this.tmp, "utf-8"));
this.threeSheet.addCell(label);
}
/**
* 粉丝性别&质量
*/
public void foursheet(Result rs) throws Exception {
this.four_index++;
label = new Label(0, this.four_index, new String(rs.getRow(), "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "nickName".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(1, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "address".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(2, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lMFansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(3, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lWFansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(4, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lVFansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(5, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lCorpseFansCount".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(6, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
this.tmp = rs.getValue(this.family, "lGrassRootsFan".getBytes());
if (this.tmp == null) {
this.tmp = "".getBytes();
}
label = new Label(7, this.four_index, new String(this.tmp, "utf-8"));
this.fourSheet.addCell(label);
}
/**
* 二级粉丝区间分布
*/
public void fivesheet(Result rs) throws Exception {
this.tmp = rs.getValue(this.family, "fan2fenbu".getBytes());
if (this.tmp == null) {
return;
}
fan_str = new String(this.tmp, "utf-8");
if (fan_str == null || fan_str.indexOf("|") <= 0) {
return;
}
arry1 = fan_str.split(" ");
for (String str : arry1) {
this.five_index++;
arry2 = str.split("\\|");
label = new Label(0, this.five_index, new String(rs.getRow(),
"utf-8"));
this.fiveSheet.addCell(label);
label = new Label(1, this.five_index, new String(rs.getValue(
this.family, "nickName".getBytes()), "utf-8"));
this.fiveSheet.addCell(label);
label = new Label(2, this.five_index, new String(rs.getValue(
this.family, "address".getBytes()), "utf-8"));
this.fiveSheet.addCell(label);
label = new Label(5, this.five_index, arry2[1]);
this.fiveSheet.addCell(label);
arry2 = arry2[0].split("_");
label = new Label(3, this.five_index, arry2[0]);
this.fiveSheet.addCell(label);
if(arry2.length<2){
label = new Label(4, this.five_index, "-1");
}else{
label = new Label(4, this.five_index, arry2[1]);
}
this.fiveSheet.addCell(label);
}
}
/**
* 粉丝地域分布
*/
public void sixsheet(Result rs) throws Exception {
this.tmp = rs.getValue(this.family, "diyufenbu".getBytes());
if (tmp == null) {
return;
}
this.fan_str = new String(this.tmp, "utf-8");
if (this.fan_str == null || this.fan_str.indexOf("|") <= 0) {
return;
}
this.arry1 = this.fan_str.split(" ");
for (String str : arry1) {
this.six_index++;
arry2 = str.split("\\|");
label = new Label(0, this.six_index, new String(rs.getRow(),
"utf-8"));
this.sixSheet.addCell(label);
label = new Label(1, this.six_index, new String(rs.getValue(
this.family, "nickName".getBytes()), "utf-8"));
this.sixSheet.addCell(label);
label = new Label(2, this.six_index, new String(rs.getValue(
this.family, "address".getBytes()), "utf-8"));
this.sixSheet.addCell(label);
label = new Label(3, this.six_index, arry2[0]);
this.sixSheet.addCell(label);
label = new Label(4, this.six_index, arry2[1]);
this.sixSheet.addCell(label);
}
}
/**
* 粉丝活跃度分布
*/
public void sevensheet(Result rs) throws Exception {
this.tmp = rs.getValue(this.family, "daywbfenbu".getBytes());
if (this.tmp == null) {
return;
}
this.fan_str = new String(this.tmp, "utf-8");
if (this.fan_str == null || this.fan_str.indexOf("|") <= 0) {
return;
}
this.arry1 = this.fan_str.split(" ");
for (String str : arry1) {
this.seven_index++;
arry2 = str.split("\\|");
label = new Label(0, this.seven_index, new String(rs.getRow(),
"utf-8"));
this.sevenSheet.addCell(label);
label = new Label(1, this.seven_index, new String(rs.getValue(
this.family, "nickName".getBytes()), "utf-8"));
this.sevenSheet.addCell(label);
label = new Label(2, this.seven_index, new String(rs.getValue(
this.family, "address".getBytes()), "utf-8"));
this.sevenSheet.addCell(label);
label = new Label(5, this.seven_index, arry2[1]);
this.sevenSheet.addCell(label);
arry2 = arry2[0].split("_");
label = new Label(3, this.seven_index, arry2[0]);
this.sevenSheet.addCell(label);
if(arry2.length<2){
label = new Label(4, this.seven_index, "-1");
}else{
label = new Label(4, this.seven_index, arry2[1]);
}
this.sevenSheet.addCell(label);
}
}
private void closeExcel() {
try {
if (this.wokbook != null) {
this.wokbook.write();
this.wokbook.close();
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
}
public void exportExcel() {
HTable htable = getHtable(FanExcel.TABLE_NAME);
Scan scan = new Scan();
Result rs = null;
int n =0;
int n2=0;
try {
ResultScanner rscan = htable.getScanner(scan);
Iterator<Result> it = rscan.iterator();
while (it.hasNext()) {
rs = it.next();
if (rs == null || rs.isEmpty()) {
continue;
}
this.oneSheet(rs);
this.twoSheet(rs);
this.threeSheet(rs);
this.foursheet(rs);
this.fivesheet(rs);
this.sixsheet(rs);
this.sevensheet(rs);
n2++;
n++;
if(n==500){
System.out.println("重新初始化操作!");
this.closeExcel();
this.init(false);
}
}
} catch (Exception ex) {
log.error(new String(rs.getRow()));
log.error(ex.getMessage(), ex);
} finally {
System.out.println("写入记录数:"+n2);
System.out.println("sheet1:"+this.one_index);
System.out.println("sheet2:"+this.two_index);
System.out.println("sheet3:"+this.three_index);
System.out.println("sheet4:"+this.four_index);
System.out.println("sheet5:"+this.five_index);
System.out.println("sheet6:"+this.six_index);
System.out.println("sheet7:"+this.seven_index);
closeExcel();
}
}
public static void main(String arg[]) {
FanExcel fanexcel = FanExcel.getFanExcel();
System.out.println("开始导出excel数据:");
fanexcel.exportExcel();
System.out.println("结束导出excel数据:");
}
}
发表评论
-
hive 安装运行权限错误Permission denied: user=hive, access=WRITE,
2013-07-24 17:10 18457在安装hive过程中遇到了hive权限错误: : E ... -
hadoop 源码编译 导入eclipse
2013-04-25 18:23 3877hadoop 源码编译 导入eclipse h ... -
hive null 和空值
2013-02-28 09:46 3601hive的数据源是基于hdfs的数据文件,如果文件的某一个字 ... -
mahout中bayes分类分析—2
2012-11-27 17:40 27342、 模型 以上训练部分的四个job 执行完毕后,整 ... -
mahout中bayes分类分析—1
2012-11-26 14:57 2024根据http://blog.163.com/jiayouwei ... -
谷歌开源 Supersonic 查询引擎
2012-11-21 11:25 1146谷歌近日开源了其Supersonic项目。据谷歌描述,Supe ... -
Cloudera Impala:基于Hadoop的实时查询开源项目
2012-11-13 11:08 1209摘要:号外!Cloudera发布了实时查询开源项目Impala ... -
hadoop 运行任务超时
2012-08-29 15:08 1189在默认指定的10分钟或具体在配置文件指定的时间内没有报告状态, ... -
Task process exit with nonzero status of 1.
2012-08-28 11:08 3137在平时跑mapReduce程序时,经常会遇到这样的错误,网上也 ... -
导出excel2007 poi3.8
2012-07-27 19:17 5489poi3.8默认情况下,用到的临时目录是系统自带的临时目录,在 ... -
hbase 导入导出
2012-07-12 19:17 3461hbase导入导出第一方案: hbase已经自带了这个命令,下 ... -
hive函数大全
2012-06-29 19:14 237961.内置运算符 1.1关系运 ... -
Hadoop Job Scheduler作业调度器
2012-06-21 11:46 4123Hadoop Job Scheduler Hadoop的作业调 ... -
关于hadoop2.0自定义计数器
2012-06-07 11:38 1780最近写了个mapReduce进行数据分析,发现数据不合理,想写 ... -
hadoop Text编码问题
2012-06-01 17:33 1933Hadoop写map/reduce作业开始,就遇到了输入数据是 ...
相关推荐
6. **终端mac查询脚本**:在Mac终端中,可以编写shell脚本来自动化这些过程,包括执行HBase查询、Hive操作、数据库导入导出等,以提高效率和减少手动错误。 这个流程体现了大数据处理中的一种典型数据流:从NoSQL...
标题 "HDFS 通过 mapreduce 进行 HBase 导入导出" 涉及的是大数据处理领域中的两个重要组件——Hadoop Distributed File System (HDFS) 和 HBase,以及它们之间的数据交互。HDFS 是 Hadoop 的分布式文件系统,而 ...
hbase-exporterHBase Prometheus导出器收集指标并中继JMX指标以供Prometheus使用由于JMX中一些重要的指标缺失或为空,因此我们另外分析了HBase主界面,例如“过渡中的过时区域” 解析“ hbase hbck”命令的输出以...
HBase是Apache软件基金会的Hadoop项目中的一个子项目,它是一个开源的非关系型分布式数据库(NoSQL),是Google Bigtable的开源实现。HBase特别适合于存储大量的稀疏数据,其设计目标是提供水平可扩展的数据存储能力...
出现此问题时使用:java.lang.NullPointerException at org.json.JSONObject.(JSONObject.java:144) at org.apache.sqoop.util.SqoopJsonUtil.getJsonStringforMap(SqoopJsonUtil.java:43) at org.apache.sqoop....
在IT行业中,尤其是在大数据处理领域,HBase是一个广泛使用的分布式、高性能、列式存储的NoSQL数据库。HBase是建立在Hadoop文件系统(HDFS)之上,为处理大规模数据提供了一个高效的数据存储解决方案。而Spring Data...
通过编写MapReduce作业,可以对HBase表进行大规模的数据导入和导出,或者执行复杂的数据分析任务。 在实际使用中,选择哪个客户端工具取决于具体的需求和使用场景。例如,如果需要快速原型开发或简单的数据操作,...
基于JavaFX + HBase API开发,...5. 核心设计:通过Apache POI 实现了 Excel(对Excel 03 和 07 版本全部支持) 和 HBase 之间数据导入和导出支持,使用 Java多线程技术使得导入Excel数据到HBase速度提升了7倍左右!
在大数据处理领域,HBase作为一个分布式、高性能的列式存储系统,被广泛应用于处理大规模结构化数据。本文将深入探讨如何使用代码实现将CSV(逗号分隔值)数据存储到HBase中,帮助你更好地理解和掌握HBase的用法。 ...
在实际应用中,你可能还需要学习如何创建表、插入数据、查询数据、管理表的列族和版本、进行数据的批量导入导出、监控HBase性能等操作。此外,HBase的运维也是一项重要任务,包括定期备份、恢复、优化等。理解HBase...
搭建pinpoint需要的hbase初始化脚本hbase-create.hbase
HBase是一种分布式、基于列族的NoSQL数据库,由Apache软件基金会开发并维护,是Hadoop生态系统中的重要组件。这份“HBase官方文档中文版”提供了全面深入的HBase知识,帮助用户理解和掌握如何在大数据场景下有效地...
### HBase权威指南知识点概述 #### 一、引言与背景 - **大数据时代的来临**:随着互联网技术的发展,人类社会产生了前所未为的数据量。这些数据不仅数量巨大,而且种类繁多,传统的数据库系统难以应对这样的挑战。 ...
4. 导入导出:工具提供数据导入和导出功能,允许用户将数据从CSV或其他格式导入到HBase,或将HBase中的数据导出到文件系统,便于数据分析和备份恢复。 5. 权限管理:对于多用户环境,权限管理是必不可少的。该管理...
《HBase数据可视化系统构建详解》 在大数据领域,HBase作为一款分布式列式数据库,因其高并发、低...在实际应用中,可以根据需求进一步扩展功能,例如支持更复杂的查询条件、数据导出导入等,以满足不同场景的需求。
### HBase 配置内置 ZooKeeper 的详细步骤与解析 #### 一、配置背景与目的 在 HBase 的部署环境中,ZooKeeper 起着非常重要的作用,它主要用于协调集群中的各个节点,并且管理 HBase 的元数据。通常情况下,HBase ...
HBase(hbase-2.4.9-bin.tar.gz)是一个分布式的、面向列的开源数据库,该技术来源于 Fay Chang 所撰写的Google论文“Bigtable:一个结构化数据的分布式存储系统”。就像Bigtable利用了Google文件系统(File System...
用户可以将CSV或Excel文件批量导入到HBase表中,也可以将数据导出为各种格式,便于数据分析或备份。这对于数据迁移和数据交换场景非常有用。 在管理层面,此工具可能还包括权限管理、监控和报警功能。例如,可以...
### HBase开启审计日志详解 #### 一、概述 HBase是一款分布式列式存储系统,基于Google的Bigtable论文实现。它具有高可靠性、高性能、面向列、可伸缩的特点,非常适合处理海量数据。在大数据领域,HBase被广泛用于...
"基于SpringBoot集成HBase过程解析" SpringBoot集成HBase是当前大数据处理和存储解决方案中的一种常见组合。HBase是基于Hadoop的分布式、可扩展的NoSQL数据库,能够存储大量的结构化和非结构化数据。SpringBoot则...