两个DBF表中如何追加字段
现有两个DBF表,a.dbf和b.dbf,字段分别是姓名,年龄和姓名,职业,其中姓名字段两个表是相同的!我想要一个新的a.dbf,字段是姓名,年龄,职业~就是在表a中追加...
现有两个DBF表,a.dbf和b.dbf,字段分别是姓名,年龄和姓名,职业,其中姓名字段两个表是相同的!我想要一个新的a.dbf,字段是姓名,年龄,职业~ 就是在表a中追加字段职业!不知道如何操作!
展开
2个回答
展开全部
public static void writeDBF() {
try {
DBFField fields[] = new DBFField[3];
fields[0] = new DBFField();
fields[0].setName("emp_code");
fields[0].setDataType(DBFField.FIELD_TYPE_C);
fields[0].setFieldLength(10);
fields[1] = new DBFField();
fields[1].setName("emp_name");
fields[1].setDataType(DBFField.FIELD_TYPE_C);
fields[1].setFieldLength(20);
fields[2] = new DBFField();
fields[2].setName("salary");
fields[2].setDataType(DBFField.FIELD_TYPE_N);
fields[2].setFieldLength(12);
fields[2].setDecimalCount(2);
DBFWriter writer = new DBFWriter();
writer.setFields(fields);
writer.setCharactersetName("GBK");
Object rowData[] = new Object[3];
rowData[0] = "1000";
rowData[1] = "李总asda";
rowData[2] = new Double(5000.00);
writer.addRecord(rowData);
rowData = new Object[3];
rowData[0] = "1001";
rowData[1] = "Lalit";
rowData[2] = new Double(3400.00);
writer.addRecord(rowData);
rowData = new Object[3];
rowData[0] = "1002";
rowData[1] = "冗笔啊11111";
rowData[2] = new Double(7350.00);
writer.addRecord(rowData);
FileOutputStream fos = new FileOutputStream("e:/aa.dbf");
writer.write(fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
DBFField fields[] = new DBFField[3];
fields[0] = new DBFField();
fields[0].setName("emp_code");
fields[0].setDataType(DBFField.FIELD_TYPE_C);
fields[0].setFieldLength(10);
fields[1] = new DBFField();
fields[1].setName("emp_name");
fields[1].setDataType(DBFField.FIELD_TYPE_C);
fields[1].setFieldLength(20);
fields[2] = new DBFField();
fields[2].setName("salary");
fields[2].setDataType(DBFField.FIELD_TYPE_N);
fields[2].setFieldLength(12);
fields[2].setDecimalCount(2);
DBFWriter writer = new DBFWriter();
writer.setFields(fields);
writer.setCharactersetName("GBK");
Object rowData[] = new Object[3];
rowData[0] = "1000";
rowData[1] = "李总asda";
rowData[2] = new Double(5000.00);
writer.addRecord(rowData);
rowData = new Object[3];
rowData[0] = "1001";
rowData[1] = "Lalit";
rowData[2] = new Double(3400.00);
writer.addRecord(rowData);
rowData = new Object[3];
rowData[0] = "1002";
rowData[1] = "冗笔啊11111";
rowData[2] = new Double(7350.00);
writer.addRecord(rowData);
FileOutputStream fos = new FileOutputStream("e:/aa.dbf");
writer.write(fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询