Free Support Forum - aspose.com

Problems with PrintTitleColumns- PrintTitleRows and FitToPageWide

Hi,

I have a problem using Asponse.Excel .NET component. The problem is that when I use PrintTitleColumns or/and PrintTitleRows and FitToPageWide, the data doesn't occupy all the space between margins, leaving a lot of space before right margin.

I use Aspose 3.1.1.5, Visual Studio .NET 2003 and MS Excel 2003.

Thanks in advance.


  1. Please set PageSetup.RightMargin to 0.
    2. If still leaving space before right margin, I think that’s the routine of MS Excel. You can verify it by manually setting PrintTitleColumns or/and PrintTitleRows and FitToPageWide in MS Excel.
    3. If I misunderstood your need, please post a sample file here and elaborate your problem.

Hi Laurence,

Here is the code that works in a wrong way.

Dim i,j As Integer
Dim excel As Aspose.Excel = new Excel()
Dim currentWorksheet As Worksheet = excel.Worksheets(0)

For i = 1 To 52
currentWorksheet.Cells.PutValue(1,i,“bbbbbbbbbb”)
Next

For i = 1 To 500
For j = 1 To 500
currentWorksheet.Cells.PutValue(i,j,“aaaaaaaaaa”)
Next
Next

currentWorksheet.PageSetup.Orientation = 0 '(Landscape)
currentWorksheet.PageSetup.LeftMargin = 0.25D
currentWorksheet.PageSetup.TopMargin = 0.25D
currentWorksheet.PageSetup.RightMargin = 0.25D
currentWorksheet.PageSetup.BottomMargin = 0.25D
currentWorksheet.PageSetup.FooterMargin = 0.25D
currentWorksheet.PageSetup.HeaderMargin = 0.25D
currentWorksheet.PageSetup.FitToPagesWide = 1
currentWorksheet.PageSetup.FitToPagesTall = 0

currentWorksheet.PageSetup.PrintTitleRows = “$” & currentWorksheet.Cells.RowIndexToName(1).ToString + “:$” & _
currentWorksheet.Cells.RowIndexToName(10).ToString

currentWorksheet.PageSetup.PrintTitleColumns = “$” & currentWorksheet.Cells.ColumnIndexToName(1).ToString + “:$” & _
currentWorksheet.Cells.ColumnIndexToName(10).ToString

With the last two lines there aren’t a good distribution between margins, but If
I delete these lines (PrintTitleRows and PrintTitleColumns), this doesn’t happens.

Could you test it??

Thanks in advance.

I tested your code and found it’s all fine. Those extra right margins are allocated by MS Excel while setting print rows/columns. So it’s a MS routine, not a problem. You can verify it by setting them in MS Excel manually.

Hi Laurence,

As you had said, I’ve verified it manually in the Excel and it seems to work fine. The margins are always ok.

I send you the excel file.

Your file works fine. But if you manually set print title rows/columns, you can also see the extra right margin.