Excel Pageset up


#1

HI,

I want to use the page set up feature of aspose.cell. In an excel if we go to the page set up, in the header/footer tab there is an option to set up custom header and footer, which has the left section, center section and the right section. How can I acheive this using Aspose.cells?

rgds

Soumya


#2

Please check http://www.aspose.com/Wiki/default.aspx/Aspose.Cells/HeadersAndFooters.html .


#3

Thanks, I could get the headers up. i also need to insert a logo into the right section , How do I do that, I tried giving the path, but dint work? Also, is it possible to give a background color for this header?


#4

Do you want to insert an image into header/footer? This feature is not supported yet but we are working on it. Hopefully it will be available in 2-3 weeks.

For backgroud color setting, I don't know how to do it because I don't find MS Excel supports such a feature.


#5

yes i need to insert a log into the header’s right section (a gif image). It would be very helpfull if you could let me know when this feature has been incorporated. Could you inform me pls?


#6

Yes. I will notify you when I make it.


#7

Hi,

I wanted to know if this feature has been indorporated now. My requirement is urgent. I also have a query regarding the pagesetup. At the moment I have a header (see the attachment) which has been created by merging cells and it spans as to the number of columns in the report. The problem is , when i print this excel report, the page breaks are set and i loset he logo. Basically its shown in the last page only. Is there a way where I can display it in each page when I print? I have tried using the Pagesetup.PrintArea option, however if the number of columns are more(like more than 30) the report is shrunk and hardly legible.

Rgds,

Soumya


#8

Hi ,

I did find a method pageSetup.SetHeaderPicture(). tried using this one to set a picture in the header. I used this code

//Obtaining the reference of the PageSetup of the worksheet

Aspose.Cells.PageSetup pageSetup = workbook.Worksheets[0].PageSetup;

//Setting worksheet name at the left section of the header

pageSetup.SetHeader(0, "&\"Times New Roman,Bold\"&14 Report" + (char)10 + "&\"Aerial\"&10 View name");

string logo_url = "C:\\Soumya\\VS2005TestProjs\\AsposeTrial\\ccsfo_logo.gif";

FileStream inFile;

byte[] binaryData;

inFile = new System.IO.FileStream(logo_url, System.IO.FileMode.Open, System.IO.FileAccess.Read);

binaryData = new Byte[inFile.Length];

long bytesRead = inFile.Read(binaryData, 0, (int)inFile.Length);

pageSetup.SetHeaderPicture(2, binaryData);

inFile.Close();

workbook.Save("report.xls", FileFormatType.Default, SaveType.OpenInBrowser, this.Page.Response);

When i check the print preview, i can see the Header text but not the image, Please tell me whats the mistake, I am attaching a copy of the excel.

Rgds,

Soumya


#9

Hi Soumya,

This method is not completed yet. You will get a new fix including this feature in 1-2 days. Thanks for your patience.


#10

Please try this attached version with following sample code:

Workbook workbook = new Workbook();
string logo_url = "d:\\1.gif";

FileStream inFile;

byte[] binaryData;

inFile = new System.IO.FileStream(logo_url, System.IO.FileMode.Open, System.IO.FileAccess.Read);

binaryData = new Byte[inFile.Length];

long bytesRead = inFile.Read(binaryData, 0, (int)inFile.Length);

PageSetup pageSetup = workbook.Worksheets[0].PageSetup;

pageSetup.SetHeaderPicture(1, binaryData);

pageSetup.SetHeader(1, "&G");


workbook.Save("d:\\test\\abc.xls");