为什么相同的“excel如何转换成图片”代码,在winform中正常,在winservice中不对
public static string GetExcel(string excelFilePath){
EXCEL.Application app = new Microsoft.Office.Interop.Excel.Application();
object objMis = Type.Missing;
EXCEL.Workbook singleExcel = app.Workbooks.Open(excelFilePath, objMis, objMis, objMis, objMis, objMis, objMis, objMis, objMis, objMis, objMis, objMis, objMis, objMis, objMis);
try
{
//wsheet.UsedRange.Select();
for (int i = 1; i <= singleExcel.Worksheets.Count; i++)
{
EXCEL.Worksheet wsheet = (EXCEL.Worksheet)singleExcel.Worksheets[i];
//Clipboard.Clear();
object ranobj = DBNull.Value;
//设置选择单元格,在复制出来。
wsheet.get_Range("A1", "Z106").Copy(ranobj);
//全选单元格,全部复制出来。
//wsheet.UsedRange.Copy(objMis);
//Clipboard.SetDataObject(objMis);
IDataObject iData = Clipboard.GetDataObject();
Bitmap bits = (Bitmap)iData.GetData(DataFormats.Bitmap);
Bitmap myBitmap = new Bitmap(bits.Width, bits.Height);
Graphics g = Graphics.FromImage(myBitmap);
g.DrawImage(bits, 0, 0);
myBitmap.Save(string.Format(SAVEEXCELJPG, Guid.NewGuid()));
Clipboard.Clear();
myBitmap.Dispose();
bits.Dispose();
}
}
catch (Exception Excel)
{
throw Excel;
}
finally
{
singleExcel.Close(objMis, objMis, objMis);
app.Quit();
}
return string.Empty;
}
从网上搜索的代码,代码在winform中正常,为什么到winservice中总是 IDataObject iData = Clipboard.GetDataObject();
获取不到数据,希望各位大侠多帮忙,谢谢 --------------------编程问答-------------------- 纠结中....请各位多帮忙 --------------------编程问答-------------------- 请我LZ后来是怎么解决这个问题的
--------------------编程问答-------------------- 在页面@Pag中加入AspCompat= "true " ,问题就可以解决了。
补充:.NET技术 , C#