View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
zoddiax zoddiax is offline
external usenet poster
 
Posts: 8
Default Problem with Excel Charting ... Please Help

I am drawing an excel chart using C#. But the chart is occupying entire plot
area no matter how many rows i give. I want to leave some space at the end of
the chart.



Suppose i am drawing chart for 400 rows, I want to see all the 400 rows on
the x axis without omitting the blank rows. How can i do that.



Following is my code




Code Block/* Open the destination file */

xlBookScript = (Excel.Workbook)xlBooks.Open(sDestinationFile, Type.Missing,
Type.Missing,

Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing,

Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing);

xlSheetExtra = (Excel.Worksheet)xlBookScript.Worksheets["Extra"];

xlSheetScript = (Excel.Worksheet)xlBookScript.Worksheets[sSheetType];

xlChart = (Excel.Chart)xlBookScript.Charts.Add(Type.Missing, Type.Missing,
Type.Missing, Type.Missing);

xlRange = xlSheetScript.get_Range("B7:B400,D7:D400,J7:J400,O 7:O400",
Type.Missing);

xlChart.ChartWizard(xlRange, Excel.XlChartType.xlLineMarkers, Type.Missing,

Excel.XlRowCol.xlColumns, Type.Missing, Type.Missing, false,

sSheetType, Type.Missing, Type.Missing, Type.Missing);







xlSeriesVol = (Excel.Series)xlChart.SeriesCollection(4);

xlSeriesVol.AxisGroup = Excel.XlAxisGroup.xlSecondary;

xlSeriesVol.ChartType = Excel.XlChartType.xlColumnClustered;

xlZAxis = (Excel.Axis)xlChart.Axes(Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlSecondary);

xlZAxis.TickLabelPosition = Excel.XlTickLabelPosition.xlTickLabelPositionNone;

xlZAxis.MajorTickMark = Excel.XlTickMark.xlTickMarkNone;

xlZAxis.MaximumScale = 3 * xlZAxis.MaximumScale;

xlZAxis.MinimumScale = 0;







/* Give the location for the chart */

xlChart.Location(Excel.XlChartLocation.xlLocationA sObject, "Extra");

xlRange = (Excel.Range)xlSheetExtra.Rows.get_Item(iRowNo, Type.Missing);

xlSheetExtra.Shapes.Item(sChartNo).Top = (float)(double)xlRange.Top;

xlRange = (Excel.Range)xlSheetExtra.Columns.get_Item(1, Type.Missing);

xlSheetExtra.Shapes.Item(sChartNo).Left = (float)(double)xlRange.Left;

xlSheetExtra.Shapes.Item(sChartNo).Height = 380;

xlSheetExtra.Shapes.Item(sChartNo).Width = 710;

xlBookScript.Close(true, Type.Missing, Type.Missing);