How do we set the position of an Excel chart from C#? -


I am trying to generate an Excel chart from C #. The chart is generated, but it appears in the center of the screen.

Thank you.

My code looks like this:

  Microsoft.Office.Interop.Excel _Workbook ebook = (Microsoft.Office.Interop.Excel._Workbook) etablo.Workbooks.Add (truth); Microsoft.Office.Interop.Excel._Worksheet esheet = (Microsoft.Office.Interop.Excel._Worksheet) ebook.ActiveSheet; _Chart grafik1 = (chart) ebook.Charts.Add (Type Messing, Type Missing, Type Missing, Type Missing); / * Add data from cell to here * / / * then * / grafik1.Location (XL Chattel space. XlLocationAsObject, esheet.Name);  

After you generate a chart, you control the chart as a shape object You can:

For example:

  esheet.shapes.Item ("Chart 1"). Top = 100; Esheet.Shapes.Item ("Chart 1"). Left = 250; // Or you can handle size by index - Let's start with index 1 esheet.Shapes.Item (1). I think, you want to determine the position of the right cells, for example:  
  esheet.shapes.Item ("Chart 1" ). Top = (float) (double) esheet.get_range ("A5", "A6"). Top;  

So ... I hope this will help :)

Luboss


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -