我用java导出txt,csv,xls格式的文件,但文件导到服务器上了,如何能将文件导到本地,
导入文件:
try
{
OutputStream os = new FileOutputStream(path);
WritableWorkbook wbook = Workbook.createWorkbook(os);// 建立excel文件
String tmptitle = "用户卡"; // 标题
WritableSheet wsheet = wbook.createSheet(tmptitle, 0); // sheet名称
// 设置excel标题
WritableFont wfont = new WritableFont(WritableFont.ARIAL, 16,WritableFont.BOLD,
false,UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
WritableCellFormat wcfFC = new WritableCellFormat(wfont);
wcfFC.setBackground(Colour.AQUA);
wsheet.addCell(new Label(1, 0, tmptitle, wcfFC));
wfont = new jxl.write.WritableFont(WritableFont.ARIAL, 14,WritableFont.BOLD,
false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);
for(int i=0;i<list.size();i++) {
String[] data = list.get(i);
wsheet.setColumnView(0,15);
wsheet.setColumnView(1,15);
wsheet.setColumnView(2,15);
wsheet.setColumnView(3,15);
wsheet.setColumnView(4,18);
wsheet.addCell(new Label(0, i+1, data[0])); //序列号
wsheet.addCell(new Label(1, i+1, data[1])); //用户卡号
wsheet.addCell(new Label(2, i+1, data[2])); //用户密码
wsheet.addCell(new Label(3, i+1, data[3])); //经销商编号
wsheet.addCell(new Label(4, i+1, data[4])); //营销平台经销商ID
}
// 主体内容生成结束
wbook.write(); // 写入文件
wbook.close();
os.close(); // 关闭流
return true;
}
catch(Exception ex)
{
ex.printStackTrace();
return false;
}