Issue with setting the bottom margin


#1

I have read all of the posts regarding margins...and followed exactly what was posted, but am still having a problem with setting the margins, specifically the bottom margin.

We are using 3.0.6.3 of the Aspose.Excel DLL.

We are looking for a 0.25" margin on the top, left, and right sides of the page, and a 0.75" margin on the bottom.

with this code:

pageSetup.TopMargin = 0.635D;
pageSetup.BottomMargin = 1.905D;
pageSetup.LeftMargin = 0.635D;
pageSetup.RightMargin = 0.635D;

it sets the top, left, and right to 0.635", and the bottom to 4.09470809755808E-06" Crying

which is not what we want. For some reason, the 0.635D (in centimeters) does not convert to 0.25", but stays at 0.635" in the spreadsheet.

Ok...so I tried this code:

pageSetup.TopMargin = 0.25D;
pageSetup.BottomMargin = 0.75D;
pageSetup.LeftMargin = 0.25D;
pageSetup.RightMargin = 0.25D;

and now the top, left, and right margins are correctly set at 0.25" when I open the spreadsheet, but the bottom margin is still not correct. Wink

Two questions:

1) what value should be passed to the properties for the margins (centimeters, inches, ...) and how?
2) is there a bug with the bottom margin property? No matter what I try, that property is not setting itself right. I believe, although I am not 100% sure, that this property was working fine in prior releases.


#2

Sorry for this bug.

In v3.0.x, we added the following properties:
TopMarginInch, BottomMarginInch, LeftMarginInch and RightMarginInch. But when doing this, bugs are introduced. We have already found and fixed these bugs. Please download and try v3.1.1 at http://www.aspose.com/Downloads/Aspose.Excel/Default.aspx.

Now you can set your margins as:

//In unit of centimeters
pageSetup.TopMargin = 0.25D;
pageSetup.BottomMargin = 0.75D;
pageSetup.LeftMargin = 0.25D;
pageSetup.RightMargin = 0.25D;

or

//In unit of inches
pageSetup.TopMarginInch = 0.1D;
pageSetup.BottomMarginInch = 0.3D;
pageSetup.LeftMarginInch = 0.1D;
pageSetup.RightMarginInch = 0.1D;


#3

Lawrence,

Thank you for your fast response! Ok…I downloaded the 3.1.1 version of the DLL, and it seems to have addressed the margin issue perfectly! However, the row height is now not working (it did work fine in 3.0.6.3). For instance:

Cells cells = excel_worksheet.Cells;

cells.SetRowHeight (lnRow-1, 11.25);

used to set the RowHeight of the specified row to 11.25, but now the row height for that row is set to 12.75 - after downloading the new DLL! Our Excel worksheets are now much bigger because this value is no longer setting properly. [:^)]

I look forward to your response…thanks in advance!


#4

something worth noting…all of the rows seem to have a rowheight of 12.75 EXCEPT for rows that do not have anything put in them - those rows have a rowheight of 9, which I do by

cells.StandardHeight = 9;

Most of the rows that have data should have a rowheight of 9, which I why I did this, but now any row that has data in it gets reset to 12.75. Any row in the worksheet that doesn’t have anything populated in it remains at a rowheight of 9. Tongue Tied


#5

Please try this attached fix. If it still doesn’t work for you, please post your code here. Thank you.


#6

Lawrence,

Thank you for your quick response. I tested the DLL attached to the last response, and it worked better - now some of the Excel rows are back to a height of 9, but some are still set at 12.75.

I have attached the code - the first part (search for PART 1) is now formatting correctly with the row height, which it wasn’t in version 3.1.1, the second part (search for PART 2) does not have the correct row height with the latest DLLs. [8-)]

Maybe - some of the formatting attributes are now overwriting or resetting the row height after they are applied, where that wasn’t happening before…???

Thanks!

Bob


#7

Hi Bob,


Please try the attached fix.


#8

Lawrence,

I tried the attached over the weekend (had trouble posting a response on the forums until today).

We are still experiencing the same behavior. Would it help if we took one of the older versions of the DLL, like 3.0.3.0 - to let you know if the row height is ok there? I would expect to have the same problem with the bottom margin that we initially reported, but if the row height problem going away, we can assume that a change to a later DLL changed the behavior. The sample code I posted is exactly how we are posting/formatting the values in the cells.

Bob


#9

Here is v3.0.3.

I tested the following code in the new dll and it works fine:

Excel excel = new Excel();
Cells cells = excel.Worksheets[0].Cells;

cells.StandardHeight = 9;

cells.SetRowHeight(0, 12);

Range range = cells.CreateRange(1, 1, 2, 2);

range.SetOutlineBorder(BorderType.TopBorder, CellBorderType.Thin, Color.Red);

cells.SetRowHeight(1, 11.5);

Could you please try it in your machine? Thanks.


#10

Lawrence,

I was not able to try our code using the older DLL as it has since been adapted to handle the style fixes put in the new versions of the DLL, and when we run the code with the older DLL in place, we get errors because of data format expectations within the code.

I have re-run the code I posted earlier, producing an Excel spreadsheet that I will attach for you to see first hand what is happening in the newer version of the DLL.

Basically, lines 21-26 and line 30 should all have a row height of 9, they did in the older versions, but not in the most recent - maybe that setting is being overwritten because of a fix in the DLL code made recently?

This project is being rolled out to 16,000 people in the near future, and we continue to appreciate the fast feedback you provide! Thanks in advance.

Bob


#11

Hi Bob,

I trimmed your code to make it running in my machine but I don’t find the problem. The attached is my test code. Could you modify it to generate the same error? Thank you very much.


#12

I found an issue which may cause this problem and I fixed it. Please try this fix instead(v3.1.1.10).


#13

Lawrence,

I have tested the attached DLL - and it looks like it addresses the row height issue!

I will post another reply as soon as I complete my testing (making sure that everything to do with the initial fix - the page margin) is also working. Thank you! Cool

Bob


#14

Lawrence,

Thank you...the bottom margin issue and the row height issue are both resolved in the latest DLL you posted here. Big Smile

Bob