乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > java <em>poi</em> 怎么读取<em>Excel</em>

java <em>poi</em> 怎么读取<em>Excel</em>

作者:乔山办公网日期:

返回目录:excel表格制作


如下7a64e59b9ee7ad94365
public static String do_post(String url, List<NameValuePair> name_value_pair) throws IOException {
        String body = "{}";
        DefaultHttpClient httpclient = new DefaultHttpClient();
        try {
            HttpPost httpost = new HttpPost(url);
            httpost.setEntity(new UrlEncodedFormEntity(name_value_pair, StandardCharsets.UTF_8));
            HttpResponse response = httpclient.execute(httpost);
            HttpEntity entity = response.getEntity();
            body = EntityUtils.toString(entity);
        } finally {
            httpclient.getConnectionManager().shutdown();
        }
        return body;
    }
    public static String do_get(String url) throws ClientProtocolException, IOException {
        String body = "{}";
        DefaultHttpClient httpclient = new DefaultHttpClient();
        try {
            HttpGet httpget = new HttpGet(url);
            HttpResponse response = httpclient.execute(httpget);
            HttpEntity entity = response.getEntity();
            body = EntityUtils.toString(entity);
        } finally {
            httpclient.getConnectionManager().shutdown();
        }
        return body;
    }


/**
* 获取7a64e78988e69d83339合并单元格的值
* @param sheet
* @param row
* @param column
* @return
*/
public String getMergedRegionValue(Sheet sheet, int row, int column) {
int sheetMergeCount = sheet.getNumMergedRegions();

for (int i = 0; i < sheetMergeCount; i++) {
CellRangeAddress ca = sheet.getMergedRegion(i);
int firstColumn = ca.getFirstColumn();
int lastColumn = ca.getLastColumn();
int firstRow = ca.getFirstRow();
int lastRow = ca.getLastRow();

if (row >= firstRow && row <= lastRow) {
if (column >= firstColumn && column <= lastColumn) {
Row fRow = sheet.getRow(firstRow);
Cell fCell = fRow.getCell(firstColumn);

return getCellValue(fCell);
}
}
}

return null;
}
得到所有的合并单元格 sourceSheet.getNumMergedRegions(); 得到某一个合并单元格 CellRangeAddress oldRange=sourceSheet.getMergedRegion(i); 起始行 oldRange.getFirstRow() ; 结束行oldRange.getLastRow() 起始列oldRange.getFirstColumn() 结束列oldRange.getLastColumn()

麻烦采纳,谢谢!

也是按行列读取的。

相关阅读

  • <em>Java</em> 利用<em>poi</em> 导出excel

  • 乔山办公网excel表格制作
  • 让用户指定导出位置这个貌似行不通,这个要根据浏览器的来定了,ie6可以让你自己选择保存的路径,但是对于chorome 和火狐而言他们有自己默认文件保存路径Java POI生成Excel表文件" sr
关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网