SetHeaderPicture


#1

Hi. I am using the printTitleRows property to repeat rows 1-7 on my first page to all other pages. This works correctly. In the head I need to repeat an image logo too, but this fails. It's posible?

I'm using the 4.8.0.0 version of Aspose.Cell.

My code is the next:

// Title Rows

Aspose.Cells.PageSetup oPageSetup = MvarWorkbook.Worksheets[prmStrSheetName].PageSetup;

oPageSetup.PrintTitleRows = prmStrPrintTitleRows; //$1:$7

byte[] binaryData;

//Creating the instance of the FileStream object to open the logo/picture in the stream

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

//Instantiating the byte array of FileStream object's size

binaryData = new Byte[inFile.Length];

//Reads a block of bytes from the stream and writes data in a given buffer of byte array.

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

//Setting the logo/picture in the central section of the page header

oPageSetup .SetHeaderPicture(1, binaryData);

//Setting the script for the logo/picture

oPageSetup .SetHeader(1, prmStrCellHeaderLogo);// prmStrCellHeaderLogo = "&B"

inFile.Close();

Thanks.


#2

Hi,


Using the latest version, I tested it works fine. Following is my test code, I have used a simple picture to set in the header.

Sample code:

//Creating a string variable to store the url of the logo/picture
string logo_url = “e:\test\school.jpg”;
//Declaring a FileStream object
FileStream inFile;
//Declaring a byte array
byte[] binaryData;
//Creating the instance of the FileStream object to open the logo/picture in the stream
inFile = new System.IO.FileStream(logo_url, System.IO.FileMode.Open, System.IO.FileAccess.Read);
//Instantiating the byte array of FileStream object’s size
binaryData = new Byte[inFile.Length];
//Reads a block of bytes from the stream and writes data in a given buffer of byte array.
long bytesRead = inFile.Read(binaryData, 0, (int)inFile.Length);

Workbook workbook = new Workbook(“e:\test\Book1.xls”);
//Creating a PageSetup object to get the page settings of the first worksheet of the workbook
PageSetup pageSetup = workbook.Worksheets[0].PageSetup;
//Setting the logo/picture in the central section of the page header
pageSetup.SetHeaderPicture(1, binaryData);
//Setting the script for the logo/picture
pageSetup.SetHeader(1, “&G”);

pageSetup.PrintTitleRows = “$1:$7”;

//Saving the workbook
workbook.Save(“e:\test2\header_pic.xls”);
//Closing the FileStream object
inFile.Close();

Please try our latest version e.g v7.0.2.1: Please download: Aspose.Cells for .NET v7.0.2.1

Thank you.

#3

當其儲存為ods格式時,不知為何其設定 pageSetup.SetHeader(1, “&G”);無效


#4

@cchuang,

请在其他线程中共享数据。 我们将重现问题并在分析后分享我们的反馈。