Problem with sheet.zoom


#1

Hi,

I am showing chart as my default page in browser.It is shown as 100% size,but i coded sheet.zoom=75% only.Why it is showing like that can we do some to show it as 75%.

Thanks,

Arun


#2

I fixed this problem. And I will give you a fix after I check y-axis issue.


#3

Please try this attached fix.


#4

Hi,

It is not working ,still it is showing 100%.When i save the chart i could not able reduce the size of chart to 75%.

One more problem i found while using aspose.

When i open chart in browser and try to save the chart save dialog is not coming.save dialog is coming for normal sheets.

Pls find the attachment.

Below code i have written to create chart.

Thanks,

Arun

'Generate the second chart sheet

Dim sheetIndex As Integer = excel.Worksheets.Add(SheetType.Chart)

Dim sheet2 As Worksheet = excel.Worksheets(sheetIndex)

sheet2.Name = "Key Measures Chart"

sheet2.Zoom = 75

'ReportPageSetUp(excel, sheet2)

Dim pageSetup As Aspose.Cells.PageSetup = excel.Worksheets(sheetIndex).PageSetup

Dim chartIndex As Integer = sheet2.Charts.Add(ChartType.Column, 5, 5, 20, 15)

Dim chart As chart = sheet2.Charts(chartIndex)

chart.Title.Text = "Trend Analysis Key Measures"

chart.Title.TextFont.Name = "Arial"

chart.Title.TextFont.Color = Color.Black

chart.Title.TextFont.Size = 12

chart.Title.TextFont.IsBold = True

'Set sheet name at the left section of header

chart.PageSetup.SetHeader(2, "&""Arial,Bold""&12" & "Treasury Management Trend Analysis")

'Set current page number at the center section of footer

chart.PageSetup.SetFooter(1, "Page " & "&P" & " of " & "&N")

chart.PageSetup.SetFooter(0, "&A")

chart.PageSetup.Orientation = PageOrientationType.Landscape

chart.PageSetup.Zoom = 75

chart.PageSetup.PrintTitleRows = "$1:$1"

chart.PageSetup.PaperSize = PaperSizeType.PaperLetter

chart.PageSetup.FitToPagesWide = 1

chart.PageSetup.FitToPagesTall = 0

pageSetup.LeftMarginInch = 0.5

pageSetup.RightMarginInch = 0.5

pageSetup.CenterHorizontally = True

'Set series

chart.NSeries.Add("Detail!B2:B" & intChartCounter, True) 'Number of Relationships"

chart.NSeries.Add("Detail!C2:C" & intChartCounter, True) 'Product Revenue

chart.NSeries.Add("Detail!D2:D" & intChartCounter, True) 'Variable Expenses

chart.NSeries.Add("Detail!E2:E" & intChartCounter, True) 'Variable Product Margin

chart.NSeries.Add("Detail!M2:M" & intChartCounter, True) 'Contribution Margin

chart.NSeries(0).Type = ChartType.Column

chart.NSeries(1).Type = ChartType.Line

chart.NSeries(2).Type = ChartType.Line

chart.NSeries(3).Type = ChartType.Line

chart.NSeries(4).Type = ChartType.Line

chart.NSeries(0).Name = "Number of Relationships"

chart.NSeries(1).Name = "Product Revenue"

chart.NSeries(2).Name = "Variable Expense"

chart.NSeries(3).Name = "Variable Product Margin"

chart.NSeries(4).Name = "Contribution Margin"

'Set Colors

chart.NSeries(0).Area.ForegroundColor = Color.Gray

chart.NSeries(0).Area.Formatting = FormattingType.Custom

chart.NSeries(1).Line.Color = Color.Red

chart.NSeries(1).Line.Style = LineType.Solid

chart.NSeries(1).Line.Weight = WeightType.WideLine

chart.NSeries(2).Line.Color = Color.Purple

chart.NSeries(2).Line.Style = LineType.Solid

chart.NSeries(2).Line.Weight = WeightType.WideLine

chart.NSeries(3).Line.Color = Color.Green

chart.NSeries(3).Line.Style = LineType.Solid

chart.NSeries(3).Line.Weight = WeightType.WideLine

chart.NSeries(4).Line.Color = Color.Blue

chart.NSeries(4).Line.Style = LineType.Solid

chart.NSeries(4).Line.Weight = WeightType.WideLine

'Set category

chart.NSeries.CategoryData = "Detail!A2:A" & intChartCounter

chart.NSeries(1).PlotOnSecondAxis = True

chart.NSeries(2).PlotOnSecondAxis = True

chart.NSeries(3).PlotOnSecondAxis = True

chart.NSeries(4).PlotOnSecondAxis = True

chart.SecondValueAxis.IsVisible = True

chart.SecondValueAxis.Title.Text = ""

chart.ValueAxis.Title.Text = "Number of Relationships"

chart.ValueAxis.Title.Rotation = 90

chart.ValueAxis.Title.TextFont.Size = 12

chart.ValueAxis.Title.TextFont.Name = "Arial"

chart.ValueAxis.Title.TextFont.Color = Color.Black

chart.ValueAxis.Title.TextFont.IsBold = True

chart.CategoryAxis.TickLabels.Font.IsBold = True

chart.IsLegendShown = True

chart.Legend.Position = LegendPositionType.Bottom

''Marker

chart.NSeries(1).MarkerForegroundColor = Color.Red

chart.NSeries(1).MarkerBackgroundColor = Color.Red

chart.NSeries(1).MarkerStyle = ChartMarkerType.Diamond

chart.NSeries(2).MarkerForegroundColor = Color.Purple

chart.NSeries(2).MarkerBackgroundColor = Color.Purple

chart.NSeries(2).MarkerStyle = ChartMarkerType.Diamond

chart.NSeries(3).MarkerForegroundColor = Color.Green

chart.NSeries(3).MarkerBackgroundColor = Color.Green

chart.NSeries(3).MarkerStyle = ChartMarkerType.Diamond

chart.NSeries(4).MarkerForegroundColor = Color.Blue

chart.NSeries(4).MarkerBackgroundColor = Color.Blue

chart.NSeries(4).MarkerStyle = ChartMarkerType.Diamond

chart.ChartArea.Border.IsVisible = False

chart.MajorGridLines.IsVisible = False


#5

I tried your code and don't find any problem:

Dim excel As Excel = New Excel()

excel.Open("d:\temp\trend.xls")

Dim intChartCounter As Integer = 14

Dim sheetIndex As Integer = excel.Worksheets.Add(SheetType.Chart)

Dim sheet2 As Worksheet = excel.Worksheets(sheetIndex)

sheet2.Name = "Key Measures Chart1"

sheet2.Zoom = 75

'ReportPageSetUp(excel, sheet2)

Dim pageSetup As Aspose.Cells.PageSetup = excel.Worksheets(sheetIndex).PageSetup

Dim chartIndex As Integer = sheet2.Charts.Add(ChartType.Column, 5, 5, 20, 15)

Dim chart As Chart = sheet2.Charts(chartIndex)

chart.Title.Text = "Trend Analysis Key Measures"

chart.Title.TextFont.Name = "Arial"

chart.Title.TextFont.Color = Color.Black

chart.Title.TextFont.Size = 12

chart.Title.TextFont.IsBold = True

'Set sheet name at the left section of header

chart.PageSetup.SetHeader(2, "&""Arial,Bold""&12" & "Treasury Management Trend Analysis")

'Set current page number at the center section of footer

chart.PageSetup.SetFooter(1, "Page " & "&P" & " of " & "&N")

chart.PageSetup.SetFooter(0, "&A")

chart.PageSetup.Orientation = PageOrientationType.Landscape

chart.PageSetup.Zoom = 75

chart.PageSetup.PrintTitleRows = "$1:$1"

chart.PageSetup.PaperSize = PaperSizeType.PaperLetter

chart.PageSetup.FitToPagesWide = 1

chart.PageSetup.FitToPagesTall = 0

pageSetup.LeftMarginInch = 0.5

pageSetup.RightMarginInch = 0.5

pageSetup.CenterHorizontally = True

'Set series

chart.NSeries.Add("Detail!B2:B" & intChartCounter, True) 'Number of Relationships"

chart.NSeries.Add("Detail!C2:C" & intChartCounter, True) 'Product Revenue

chart.NSeries.Add("Detail!D2:D" & intChartCounter, True) 'Variable Expenses

chart.NSeries.Add("Detail!E2:E" & intChartCounter, True) 'Variable Product Margin

chart.NSeries.Add("Detail!M2:M" & intChartCounter, True) 'Contribution Margin

chart.NSeries(0).Type = ChartType.Column

chart.NSeries(1).Type = ChartType.Line

chart.NSeries(2).Type = ChartType.Line

chart.NSeries(3).Type = ChartType.Line

chart.NSeries(4).Type = ChartType.Line

chart.NSeries(0).Name = "Number of Relationships"

chart.NSeries(1).Name = "Product Revenue"

chart.NSeries(2).Name = "Variable Expense"

chart.NSeries(3).Name = "Variable Product Margin"

chart.NSeries(4).Name = "Contribution Margin"

'Set Colors

chart.NSeries(0).Area.ForegroundColor = Color.Gray

chart.NSeries(0).Area.Formatting = FormattingType.Custom

chart.NSeries(1).Line.Color = Color.Red

chart.NSeries(1).Line.Style = LineType.Solid

chart.NSeries(1).Line.Weight = WeightType.WideLine

chart.NSeries(2).Line.Color = Color.Purple

chart.NSeries(2).Line.Style = LineType.Solid

chart.NSeries(2).Line.Weight = WeightType.WideLine

chart.NSeries(3).Line.Color = Color.Green

chart.NSeries(3).Line.Style = LineType.Solid

chart.NSeries(3).Line.Weight = WeightType.WideLine

chart.NSeries(4).Line.Color = Color.Blue

chart.NSeries(4).Line.Style = LineType.Solid

chart.NSeries(4).Line.Weight = WeightType.WideLine

'Set category

chart.NSeries.CategoryData = "Detail!A2:A" & intChartCounter

chart.NSeries(1).PlotOnSecondAxis = True

chart.NSeries(2).PlotOnSecondAxis = True

chart.NSeries(3).PlotOnSecondAxis = True

chart.NSeries(4).PlotOnSecondAxis = True

chart.SecondValueAxis.IsVisible = True

chart.SecondValueAxis.Title.Text = ""

chart.ValueAxis.Title.Text = "Number of Relationships"

chart.ValueAxis.Title.Rotation = 90

chart.ValueAxis.Title.TextFont.Size = 12

chart.ValueAxis.Title.TextFont.Name = "Arial"

chart.ValueAxis.Title.TextFont.Color = Color.Black

chart.ValueAxis.Title.TextFont.IsBold = True

chart.CategoryAxis.TickLabels.Font.IsBold = True

chart.IsLegendShown = True

chart.Legend.Position = LegendPositionType.Bottom

''Marker

chart.NSeries(1).MarkerForegroundColor = Color.Red

chart.NSeries(1).MarkerBackgroundColor = Color.Red

chart.NSeries(1).MarkerStyle = ChartMarkerType.Diamond

chart.NSeries(2).MarkerForegroundColor = Color.Purple

chart.NSeries(2).MarkerBackgroundColor = Color.Purple

chart.NSeries(2).MarkerStyle = ChartMarkerType.Diamond

chart.NSeries(3).MarkerForegroundColor = Color.Green

chart.NSeries(3).MarkerBackgroundColor = Color.Green

chart.NSeries(3).MarkerStyle = ChartMarkerType.Diamond

chart.NSeries(4).MarkerForegroundColor = Color.Blue

chart.NSeries(4).MarkerBackgroundColor = Color.Blue

chart.NSeries(4).MarkerStyle = ChartMarkerType.Diamond

chart.ChartArea.Border.IsVisible = False

chart.MajorGridLines.IsVisible = False
excel.Save("d:\test\abc.xls")

To open chart sheet as default sheet, please use Worksheets.ActiveSheetIndex to set the chart sheet as the first shown sheet.

Please check if you do use the latest fix. I upload a new fix here. It's v3.7.2.4. Please check the version number in your project.


#6

Hi,

I tried with your fix,but couldn't successed.

Thanks,

Arun


#7

Please check the version number in your project to see if the new dll is deployed.

Attached is the output file created with my sample code. Please check "Key Measures Chart1" sheet.


#8

Hi,

I am using right version of dll which you sent,but couldn't successed.Please put the default page as chart in you code.

Thanks,

Arun


#9

It’s fine while setting the default page to chart. Please check the attached file.


#10

This is the code file.


#11

Hi,

Try to open the chart in browser at runtime,it is showing still 100%.Include this code

excel.Save("abc.xls", SaveType.OpenInBrowser, FileFormatType.Default, Me.Response)

and one more problem is when i try to click on file "save as" button of browser it is not displaying save dialog.

Thanks,

Arun


#12

Yes. I found the zoom problem in this situation. I will check this issue.

However, when I click "File"->"Save as", it works fine.


#13

I think this zoom issue is caused by IE and MS Excel. You can use the following code to re-produce it without Aspose.Cells.

Dim fs As FileStream = File.OpenRead("d:\test\book1.xls")

Dim data1() As Byte = New Byte(fs.Length) {}
fs.Read(data1, 0, data1.Length)


Me.Response.ContentType = "application/xls"
Response.AddHeader("content-disposition", "inline; filename=book1.xls")
Response.BinaryWrite(data1)
Response.End()

Attached is book1.xls.