问题描述
求代码!
解决方案
解决方案二:
IO流...具体没做过--
解决方案三:
补充一下,这个代码怎么读不出来图片?EXCEL是2007,两列,其中一列是图片,占7行,请高手帮忙试试usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingMicrosoft.Office.Interop.Excel;usingSystem.Windows.Forms;usingSystem.IO;usingSystem.Drawing;publicpartialclassDefault2:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){Read_excel_withpicture();}publicstaticreadonlystringpath=HttpContext.Current.Server.MapPath("~/img/1.xlsx");publicstaticreadonlystringconStr=null;//ConfigurationSettings.AppSettings["strConn"].ToString();publicvoidRead_excel_withpicture(){Excel.Applicationexcel=newExcel.Application();Excel.Workbookworkbook=excel.Workbooks.Add(path);excel.UserControl=true;excel.Visible=true;System.Text.StringBuildersb=newSystem.Text.StringBuilder();Excel.Worksheetsheet=workbook.Worksheets.get_Item(1)asExcel.Worksheet;for(introw=2;row<=sheet.UsedRange.Rows.Count;row++){//取单元格值;for(intcol=1;col<=sheet.UsedRange.Columns.Count;col++){Microsoft.Office.Interop.Excel.Rangerange=sheet.Cells[row,col]asMicrosoft.Office.Interop.Excel.Range;sb.Append(col.ToString()+":"+range.Text+"<br>");}//取存图片;if(sheet.Shapes.Count>0){Bitmappicture;IDataObjectdata=null;foreach(Excel.Shapeiteminsheet.Shapes){item.Copy();data=Clipboard.GetDataObject();if(null!=data){picture=(Bitmap)data.GetData(DataFormats.Bitmap);picture.Save(string.Format(@"D:tempaa{0}.jpg",row));}}}}Response.Write(sb.ToString());workbook.Close(false,null,null);excel.Quit();}}