求 一个 JAVA的程序,要求.在坐标内,用定积分(上限,下限)求出 不规则图形的面积如果只经过1条曲线,面积为 http://foro.gabrielortiz.com/imagenes/formula_area_poligono.gif如果经过多条...我不知道怎么求....
JAVA 求 不规则 面积
答案:1 悬赏:80
解决时间 2021-05-24 21:17
- 提问者网友:白柏唇蜜
- 2021-05-24 02:36
最佳答案
- 二级知识专家网友:都不是誰的誰
- 2021-05-24 03:04
只是简单地将excel中数据转化为table 不完善有兴趣你自己完善一下
package excelTeat;
import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;import java.text.SimpleDateFormat;import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFCell;import org.apache.poi.hssf.usermodel.HSSFDateUtil;import org.apache.poi.hssf.usermodel.HSSFRow;import org.apache.poi.hssf.usermodel.HSSFSheet;import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class XlsToHtml {
public XlsToHtml(String fileName){ InputStream is = null ; try { is = new FileInputStream(fileName); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } htmlString = ""; try { hwb = new HSSFWorkbook(is) ; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public String getTable(){ StringBuffer content = new StringBuffer(); for (int numSheets = 0; numSheets < hwb.getNumberOfSheets(); numSheets++){ content.append("<table border=\"1\">"); HSSFSheet aSheet = hwb.getSheetAt(numSheets); if (null == aSheet) { continue; } for (int rowNum = 0; rowNum <= aSheet.getLastRowNum(); rowNum++){ HSSFRow aRow = aSheet.getRow(rowNum); if (null == aRow) { continue; } content.append("<tr>"); for (short cellNum = 0; cellNum <= aRow.getLastCellNum(); cellNum++) { HSSFCell aCell = aRow.getCell(cellNum); if (null == aCell) { continue; }
content.append("<td>"); if (aCell.getCellType() == HSSFCell.CELL_TYPE_STRING) { content.append(aCell.getRichStringCellValue() .getString()); } else if (aCell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { boolean b = HSSFDateUtil.isCellDateFormatted(aCell); if (b) { Date date = aCell.getDateCellValue(); SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd"); content.append(df.format(date)); } else { content.append(aCell.getNumericCellValue()); } } content.append("</td>"); }
content.append("</tr>"); } content.append("</table>"); } return content.toString(); } public static void main(String[] args) { // TODO Auto-generated method stub XlsToHtml temp = new XlsToHtml("D:\\沈阳军区\\google download\\Downloads\\xls\\08-09第二学期课表1.xls"); System.out.println(temp.getTable());// System.out.println(getContent("D:\\沈阳军区\\google download\\Downloads\\xls\\08-09第二学期课表1.xls")); } private HSSFWorkbook hwb; private String htmlString;}
package excelTeat;
import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;import java.text.SimpleDateFormat;import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFCell;import org.apache.poi.hssf.usermodel.HSSFDateUtil;import org.apache.poi.hssf.usermodel.HSSFRow;import org.apache.poi.hssf.usermodel.HSSFSheet;import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class XlsToHtml {
public XlsToHtml(String fileName){ InputStream is = null ; try { is = new FileInputStream(fileName); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } htmlString = ""; try { hwb = new HSSFWorkbook(is) ; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public String getTable(){ StringBuffer content = new StringBuffer(); for (int numSheets = 0; numSheets < hwb.getNumberOfSheets(); numSheets++){ content.append("<table border=\"1\">"); HSSFSheet aSheet = hwb.getSheetAt(numSheets); if (null == aSheet) { continue; } for (int rowNum = 0; rowNum <= aSheet.getLastRowNum(); rowNum++){ HSSFRow aRow = aSheet.getRow(rowNum); if (null == aRow) { continue; } content.append("<tr>"); for (short cellNum = 0; cellNum <= aRow.getLastCellNum(); cellNum++) { HSSFCell aCell = aRow.getCell(cellNum); if (null == aCell) { continue; }
content.append("<td>"); if (aCell.getCellType() == HSSFCell.CELL_TYPE_STRING) { content.append(aCell.getRichStringCellValue() .getString()); } else if (aCell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { boolean b = HSSFDateUtil.isCellDateFormatted(aCell); if (b) { Date date = aCell.getDateCellValue(); SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd"); content.append(df.format(date)); } else { content.append(aCell.getNumericCellValue()); } } content.append("</td>"); }
content.append("</tr>"); } content.append("</table>"); } return content.toString(); } public static void main(String[] args) { // TODO Auto-generated method stub XlsToHtml temp = new XlsToHtml("D:\\沈阳军区\\google download\\Downloads\\xls\\08-09第二学期课表1.xls"); System.out.println(temp.getTable());// System.out.println(getContent("D:\\沈阳军区\\google download\\Downloads\\xls\\08-09第二学期课表1.xls")); } private HSSFWorkbook hwb; private String htmlString;}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯