Solved

VB 2005 VSTO: Display part of a managed spreadsheet within a form.

Posted on 2006-11-16
13
429 Views
Last Modified: 2013-12-03
Hi

Is it possible to display part of a managed Excel spreadsheet
within a Windows form.

Thanks

0
Comment
Question by:murbro
  • 6
  • 6
13 Comments
 
LVL 13

Expert Comment

by:newyuppie
ID: 17955644
you would need a 3rd party tool to show it exactly like a spreadsheet. a workaround could be to store the cell values in a datatable and show them in a datagridview.
0
 

Author Comment

by:murbro
ID: 17955667
Hi Thanks

I actually just need it to show a single cell (or maybe 16 cells), to show the effects of different
combined formatting.

If the user chooses to format say borders and the color of the font, I want the cell to show the combined effect.

Thanks

0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17955731
there is another simpler option if it suits you. you could open an instance of excel from VBNET and do your formatting directly in a new Excel spreadsheet by using the interoperability inherent to .net
0
 
LVL 4

Expert Comment

by:AndyAelbrecht
ID: 17956046
another solution might be to use the activex Excel object which is meant for websites; this component gives you access to nearly all of Excels functionality and you can put it in your project. it even acts almost completely the same as a real Excel.exe !

I've used this extensively in one of my projects and I have to say this works nicely.

if you need any help locating the control or have some example code, just lemme know; I have a bunch of example code about it :)

hope this helps a bit,
Andy
0
 

Author Comment

by:murbro
ID: 17956396
Hi thanks

newyuppie: is there a way that you could see a few cells of a managed spreadsheet within a form?

AndyAelbrecht: would it be possible to give me an example
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17956493
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:murbro
ID: 17956645
Hi newyuppie. Which topic on that page?
0
 
LVL 13

Accepted Solution

by:
newyuppie earned 500 total points
ID: 17956722
check the "How To: Refer to Worksheet Ranges in Code", and the "Apply styles to Ranges in Worksheet"

http://msdn2.microsoft.com/en-us/library/1ad4d8d6(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/f1hh9fza(VS.80).aspx
0
 

Author Comment

by:murbro
ID: 17956838
Great thanks
0
 

Author Comment

by:murbro
ID: 17956883
Incidentally. Is there a way to copy the formatting applied in one spreadsheet to that in another.  I could have my users format a test area in the managed spreasheet project, that would be copied to the specified range at runtime.
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17957128
thanks for the points.
following this link: http://msdn2.microsoft.com/en-us/library/f1hh9fza(VS.80).aspx
"How to Apply Styles to Ranges in Workbook"
for example have your users select the formatting they want, and then you can create a new style based on that formatting:


Dim style As Excel.Style = Globals.ThisWorkbook.Styles.Add("NewStyle")
style.Font.Name = "Verdana"
style.Font.Size = 12
style.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red)
style.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Gray)
style.Interior.Pattern = Excel.XlPattern.xlPatternSolid

then to copy this style to a range
Dim rng As Excel.Range = Me.Application.Range("A1")
rng.Style = "NewStyle"



0
 

Author Comment

by:murbro
ID: 17957728
Excellent. Thanks very much for that. Really appreciate the added help.
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17957856
sure, if you have any more problems post them here anyway.
NY
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net - For Loop Error 5 36
VB.net/WinForms: adjust Screen Resolution 6 41
Allow User To Arrange Columns At Datagridview 3 19
Vb. Net application freezes 9 30
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now