//Create a new Workbook.
Workbook workbook = new Workbook()
//Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0)
//Set the name of worksheet
sheet.setName("Data")
//Get the cells collection in the sheet.
Cells cells = workbook.getWorksheets().get(0).getCells()
//Put some values into a cells of the Data sheet.
cells.get("A1").setValue("Region")
cells.get("A2").setValue("France")
cells.get("A3").setValue("Germany")
cells.get("A4").setValue("England")
方法是可行的,不过要2次IO *** 作了~另外也可以存成流形式,再调整大小保存:
Document doc = new Document(Server.MapPath("~/test.doc"))
using (Stream stream = new MemoryStream())
{
doc.Save(stream, SaveFormat.Jpeg)
using (System.Drawing.Image image = Bitmap.FromStream(stream)) // 原始图
{
using (Bitmap image2 = new Bitmap(image, 400, 300))
{
image2.Save(Server.MapPath("~/test.jpg"))
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)