Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Generated file--charts squish when saved in .xls format, ok in .xl

I've got a c# program that's used to dynamically create spreadsheets. At the
end, I save the workbook both as an .xlsx file as well as a .xls file. My
problem is that the charts in the .xls file, although the box remains the
same size, the contents (bars, height of the vertical axis) get
"squished"--that is, there is more space in the bottom half then there should
be causing the rest to resize to fit (happens most noticably vertically, but
also slightly horizontally). I've narrowed it down to finding out that the
presence of textboxes in the chart "causes" it to squish. If I don't have
the textboxes, the chart appears normal. Can anyone think of something that
may cause this? I'm opening both files in Excel 2007.

Here is the code relating to text box creation I'm using:

Excel.Shape label =
chartobj.Chart.Shapes.AddLabel(Microsoft.Office.Co re.MsoTextOrientation.msoTextOrientationHorizontal , 75, 15, 140, 140);
label.Select(Type.Missing);
label.TextFrame.Characters(Missing.Value, Missing.Value).Text = "Very High
Risk";
label.TextFrame.AutoSize = true;
label.ControlFormat.PrintObject = true;

chartobj.Chart.ChartArea.AutoScaleFont = false;
Excel.TextBoxes textBoxes =
(Excel.TextBoxes)chartobj.Chart.TextBoxes(Type.Mis sing);
textBoxes.Font.Name = "Arial";
textBoxes.Font.Size = 16;
textBoxes.AutoScaleFont = false;
textBoxes.PrintObject = true;
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Generated file--charts squish when saved in .xls format, ok in .xl

I've found the problem. There seems to be an Excel bug when saving a chart
with the zoom on and a textbox inserted. It can be easily reproduced in
Excel 2007 (not sure if this is specific to 2003 compatability mode or if it
happens in native 2003 as well). This is not an issue saving as .xlsx.
1. Create a couple rows of data and create a bar chart (I used a 2D stacked
bar).
2. From Chart Tools--Layout, insert a Text Box in the chart.
3. Set View--Zoom to 50%.
4. Save as 2003 document and close.
5. Open the document
You will see that the while the chart box is the same size, the contents
inside have shrunk.
6. Save, close and open repeatedly and the contents keep shrinking away.
If step 2 is omitted, there is no problem. The issue is with the text box
combined with the zoom.


"Jeff Donkersgoed" wrote:

I've got a c# program that's used to dynamically create spreadsheets. At the
end, I save the workbook both as an .xlsx file as well as a .xls file. My
problem is that the charts in the .xls file, although the box remains the
same size, the contents (bars, height of the vertical axis) get
"squished"--that is, there is more space in the bottom half then there should
be causing the rest to resize to fit (happens most noticably vertically, but
also slightly horizontally). I've narrowed it down to finding out that the
presence of textboxes in the chart "causes" it to squish. If I don't have
the textboxes, the chart appears normal. Can anyone think of something that
may cause this? I'm opening both files in Excel 2007.

Here is the code relating to text box creation I'm using:

Excel.Shape label =
chartobj.Chart.Shapes.AddLabel(Microsoft.Office.Co re.MsoTextOrientation.msoTextOrientationHorizontal , 75, 15, 140, 140);
label.Select(Type.Missing);
label.TextFrame.Characters(Missing.Value, Missing.Value).Text = "Very High
Risk";
label.TextFrame.AutoSize = true;
label.ControlFormat.PrintObject = true;

chartobj.Chart.ChartArea.AutoScaleFont = false;
Excel.TextBoxes textBoxes =
(Excel.TextBoxes)chartobj.Chart.TextBoxes(Type.Mis sing);
textBoxes.Font.Name = "Arial";
textBoxes.Font.Size = 16;
textBoxes.AutoScaleFont = false;
textBoxes.PrintObject = true;

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format Cells dialog is not displayed when file generated with XLS Malhar[_2_] Excel Programming 0 October 8th 09 07:16 PM
Number Format on Excel File saved from .html file joyfulone Excel Discussion (Misc queries) 3 April 15th 09 12:07 AM
Capture Events on programmatically generated Charts INTP56 Excel Programming 3 January 16th 08 01:45 PM
What format are files saved in when printing to a file from Excel RonVanNost Excel Programming 1 June 1st 05 07:08 PM
Open file saved in HTML format Sheela Excel Programming 4 September 8th 03 05:25 AM


All times are GMT +1. The time now is 03:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"