|
-
Apr 28th, 2013, 02:20 AM
#1
Thread Starter
Member
-
Apr 28th, 2013, 01:54 PM
#2
Re: Render one cell as image (from XLS,XLSX)
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 28th, 2013, 07:25 PM
#3
Thread Starter
Member
Re: Render one cell as image (from XLS,XLSX)
Mm nice, I didn't even try simple thing as that :O
I select B3 CTRL+C/V it to Paint and get what I want...
But, how to do that with VB/C#? I must embed and COM control or something like that? Or it can be done without that visual things?
Thanks,
Stefan
-
Apr 29th, 2013, 09:47 AM
#4
Re: Render one cell as image (from XLS,XLSX)
vb.net Code:
Dim oExcel As New Microsoft.Office.Interop.Excel.Application
Dim oBook As Microsoft.Office.Interop.Excel.Workbook
Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
oBook = oExcel.Workbooks.Open("C:\TestBook.xlsx")
oSheet = CType(oBook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
Dim r As Microsoft.Office.Interop.Excel.Range = oSheet.Range("b3")
Try
r.CopyPicture(Microsoft.Office.Interop.Excel.XlPictureAppearance.xlScreen, Microsoft.Office.Interop.Excel.XlCopyPictureFormat.xlBitmap)
PictureBox1.Image = My.Computer.Clipboard.GetImage
Catch ex As Exception
TextBox1.Text = ex.Message
Finally
oExcel.Quit()
End Try
End Sub
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 30th, 2013, 06:13 PM
#5
Thread Starter
Member
Re: Render one cell as image (from XLS,XLSX)
I already find something similar on MSDN, but this your sample is much easier to understand. Thank you very much.
I will mark my thread as RESOLVED and add reputation to your post
-
May 11th, 2013, 11:07 PM
#6
Thread Starter
Member
Re: Render one cell as image (from XLS,XLSX)
Unfortunately I get another problem...
I didn't even think about this situation. Most of PCs where this app will work have Windows XP/7 and Office 2007. I developing my app on Win7 (I set target framework .NET 3.5) and Office 2013 (COM Interop Excel 15/2013).
When I try to run app on machines with Win7 and Office 2007 I get error like "Object reference not set to an instance of an object" (with MS.Office.Interop.Excel.dll)
When I try to run app on machines with WinXP and Office 2007 it works with Office.Interop.Excel.dll (when I set "copy local" to true)
Without copy local set to true (dll) app doesn't work at all. Just crash instantly.
Anybody have idea how to solve this? If install Office 2007 and develop app with older Office.Interop on my PC does that mean that my app will work on PCs with Office 2007 and 2013?
Thanks in advice,
Stefan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|