I am using Aspose to export Datatables. I want to put a dynamic title on top of the datatable. I managed to add it using Header but I don’t manage to format it.
To begin I just want to set FontSize to 24. But It remains the default size.
Below is my code. Can you help me ?
public void ExportCsvDataTable<T>(HttpResponse response, List<T> datas, TemplateFichierExporteDatatable template)
{
var donnees = ExportDataTable(datas, template);
var book = new Workbook();
var sheet = book.Worksheets[0];
foreach (var donnee in donnees)
{
sheet.Cells.ImportDataTable(donnee, true, 0, 0);
}
PageSetup pageSetup = sheet.PageSetup;
pageSetup.SetHeader(1, template.TitreFichier + "&24");
var saveOptions = new TxtSaveOptions(Aspose.Cells.SaveFormat.CSV);
saveOptions.Separator = ';';
saveOptions.Encoding = new UTF8Encoding(true);
// Adding Default Style to the table
book.Save(response, string.Concat(template.NomFichier, " - ", DateTime.Now.ToShortDateString(), ".csv"), ContentDisposition.Attachment, saveOptions);
}
Yes, the font size should be placed before string content. See the description/text for your reference:
“&<FontSize>” —> Represents font size. e.g “&14abc”. But, if this command is followed by a plain number to be printed in the header, this should be separated from the font size with a space character. For example: “&14 123”.
Well, the line of code is ok. Here “Hello World!” text will be using the default font with its size but the numeric value “123” will be pasted using font “Courier New” with size “14”.
// Setting a string at the left section of the footer and changing the font
// of the footer
pageSetup.SetFooter(0, “Hello World! &“Courier New”&14 123”);
You should replace the description with this :
// Setting a string at the left section of the footer and changing the font
// of a part of this string (“123”)