We are trying to read the Headers and Footers, but when the text contains the commands, like Page number or SheetName, we’re getting null as Text even though the Type is proper.
ws.Name is “Activity”
s being passed as &A
ws.PageSetup.GetCommands(s) is returning one item with Type as SheetName but Text as null
private String GetHeaderFooterText(Worksheet ws, String s)
{
StringBuilder ret = new StringBuilder();
IgnoreExceptionHelper.Do(() =>
{
if (s != null && ws.PageSetup.GetCommands(s) != null)
{
foreach (HeaderFooterCommand hfc in ws.PageSetup.GetCommands(s))
{
ret.Append(hfc.Text);
}
}
});
return ret.ToString();
}
Can you help us out here?
Or let us know if we have to follow different approach to achieve the expected result.