We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Header formatting issue

Hello!


I am trying to parse excel header / footer formatting with Aspose.Cells for .NET. I’ve read this article http://www.aspose.com/docs/display/cellsnet/Setting+Headers+and+Footers , but some points are still not clear to me:
  1. Do you have any API to parse commands in header text, or it is up to an end user?
  2. Anyway it seems like your manual is incomplete. For example custom font foreground produces the following header text [see attached file]: “This is the &KFF0000header sample”. Just like that, without any spaces between a command and a following word. And i didn’t find any format specs on the internet…
Sergey

Hi,


Thanks for the template file and details.

If you need to retrieve the headers/footer (scripts/commands with contents) for different sections in the template file sheet, you may try the following sample code. I have retrieved the left header and set it for the middle section accordingly.
e.g
Sample code:

Workbook excel = new Workbook(“e:\test2\header_sample.xlsx”);

Worksheet worksheet = excel.Worksheets[0];
PageSetup pagesetup = worksheet.PageSetup;
string headersection1 = pagesetup.GetHeader(0); //Get the header scripts/ command in the left section
MessageBox.Show(headersection1);

//Set the similar header with scripts/commands retrieved for the middle section.

pagesetup.SetHeader(1, headersection1);
excel.Save(“e:\test2\outasdfasdf1.xlsx”);

Thank you.

Ok, i don’t have any trouble getting or setting a header text. I have troubles with commands in a header text (&P, &D etc). So, once again:

  1. Do you have any API to parse commands in header or footer?
  2. I provided you an example of a header script command, which is not described in your article, so i want to know if there is a complete specification of the command codes?
If you don’t get me, any qualifing questions are welcome!

Sergey

Hi,

Well, yes, the document (http://www.aspose.com/docs/display/cellsnet/Setting+Headers+and+Footersv) may not be covering all possible commands/ scripts, we will check if we enhance it further.

1) I am afraid, you have to write the scripts by yourself when setting headers/ footers in the spreadsheet. You may try to get header/footer scripts with contents from the template Excel files and specify the header/footer accordingly as per my sample code.

2) As I said, we may check if we could enhance the article further. I think the article provides general scripts/ command and basic examples set only. But, I think it might not be possible to cover all possible scenarios for headers/ footers commands/ scripts.

Thank you.