Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste bitmap to Excel
When the following function is run by a Windows program it works just fine.
When it is run from an ASP.NET page the xlWorkSheet.PasteSpecial line generates: "Exception from HRESULT: 0x800A03EC." The page is set up with the aspcompat="true" page directive to avoid an exception about the lack of a Single threaded apartment. It is also run with impersonation to the same user that runs the Windows executable. Any ideas, or other ways to get a bitmap into the sheet? using System; using System.Reflection; using System.Globalization; using System.Windows.Forms; using System.Drawing; using Excel = Microsoft.Office.Interop.Excel; public void PasteBitmap() { CultureInfo oC = System.Threading.Thread.CurrentThread.CurrentCultu re; System.Threading.Thread.CurrentThread.CurrentCultu re = new CultureInfo("en-US"); // To work around bug 320369 Excel.Application xl = new Excel.Application(); xl.Visible = false; Excel.Workbook xlWorkBook = xl.Workbooks.Add(Missing.Value); Excel.Worksheet xlWorkSheet = (Excel.Worksheet)xlWorkBook.ActiveSheet; Image logo = Image.FromFile("D:\\Images\\logo.bmp"); Clipboard.SetDataObject(logo); Excel.Range xlRange = (Excel.Range)xlWorkSheet.Cells[1,1]; xlRange.Select(); xlWorkSheet.PasteSpecial("Bitmap",false,false,stri ng.Empty,0,string.Empty,true); System.Runtime.InteropServices.Marshal.ReleaseComO bject (xlRange); System.Runtime.InteropServices.Marshal.ReleaseComO bject (xlWorkSheet); System.Runtime.InteropServices.Marshal.ReleaseComO bject (xlWorkBook); System.Runtime.InteropServices.Marshal.ReleaseComO bject (xl); xlRange = null; xlWorkSheet = null; xlWorkBook = null; xl = null; System.Threading.Thread.CurrentThread.CurrentCultu re = oC; } |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Cannot copy Excel 2007 Chart and Paste as Bitmap into Powerpoint 2 | Charts and Charting in Excel | |||
How to paste a bitmap-excel paste doesn't work... | Excel Discussion (Misc queries) | |||
Excel copies as a bitmap | Excel Discussion (Misc queries) | |||
How can I put text over a bitmap picture in Excel? | Excel Discussion (Misc queries) | |||
Writing bitmap to Excel Spreadsheet | Excel Programming |