这是一种内联w/将大型ResultSet写入文件但有问题的文件是Excel文件.
我正在使用Apache POI库编写一个Excel文件,其中包含从ResultSet对象检索到的大型数据集.数据范围从几千条记录到大约一百万条; 不确定这如何转换为Excel格式的文件系统字节.
以下是我编写的测试代码,用于检查编写如此大的结果集所花费的时间以及CPU和内存的性能影响.
protected void writeResultsetToExcelFile(ResultSet rs, int numSheets, String fileNameAndPath) throws Exception {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileNameAndPath));
int numColumns = rs.getMetaData().getColumnCount();
Workbook wb = ExcelFileUtil.createExcelWorkBook(true, numSheets);
Row heading = wb.getSheetAt(0).createRow(1);
ResultSetMetaData rsmd = rs.getMetaData();
for(int x = 0; x < numColumns; x++) {
Cell cell = heading.createCell(x+1);
cell.setCellValue(rsmd.getColumnLabel(x+1));
}
int rowNumber = 2;
int sheetNumber = 0;
while(rs.next()) {
if(rowNumber == 65001) {
log("Sheet " + sheetNumber + "written; moving onto to sheet …Run Code Online (Sandbox Code Playgroud) 如何bash在MAC OSX上使用VBA 运行文件
我尝试了以下代码
location = FolderPath(ThisWorkBook.FullName)
Run Code Online (Sandbox Code Playgroud)
它返回当前目录减去文件名.
其次是
Shell(location &"runmybatch.sh")
Run Code Online (Sandbox Code Playgroud)
我这样做是因为bash脚本与excel电子表格位于同一文件夹中.
我们有一个使用Struts 1.2.9的遗留应用程序.该应用程序目前是国际化的标准方式 - .properties所有UI标签,错误,消息等的文件; 使用默认和定义的<message-resouces>每个.properties文件的定义; 在所有JSP中的用法.到目前为止,这已经发挥了很大作用,但事实上,应用程序本身是一个内部使用的几百个(是100个!)其他应用程序的服务框架.struts-config.xmlFactoryMessageResources<bean:message>
我们要求扩展i18n功能如下:
.properties文件定义自定义目录- 因此这将超出类路径的范围; 基本上不在.war包内.我们的想法是只支持消息字符串更改,而不必重新部署整个应用程序.Locale设置的方法 - 禁止所有其他注意事项(默认堆栈,类路径/包查找等),这类似于I18nInterceptorStruts2中requestOnlyParameterName设置属性的方式true.是的,我确实理解同时加载的100个捆绑包将占用大量内存,但在我们的案例中这是可以接受的.
感谢任何帮助 - 无论是方向,示例代码等.
注意:我完全同意,迁移到更新的UI平台可能是最好的解决方案.但我们做不到.
TIA.
我正在寻找一种在 Java 中导出到 CSV 文件时保留整数前导零的方法。以下是在 CSV 中生成前导零的示例。
public class TestLargeDataset {
int one_million = 1000000;
public void writeMillionRowsToCSVFile(String fqname) throws Exception {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(fqname)));
byte[] newLine = "\n".getBytes();
for(int x = 0; x < one_million; x++) {
bos.write(("0" + x + ",").getBytes());
bos.write(("0" + (x+1) + ",").getBytes());
bos.write(("0" + (x+2) + ",").getBytes());
bos.write(("0" + (x+3)).getBytes());
bos.write(newLine);
}
bos.close();
}
/*
* Main.
*/
public static void main(String a[]) throws Exception {
TestLargeDataset tlr = new …Run Code Online (Sandbox Code Playgroud)