Utilisation des en-têtes et pieds de page
Contents
[
Hide
]
Aspose.Cells - Utilisation des en-têtes et pieds de page
C#
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Workbook object
WorksheetCollection worksheets = workbook.Worksheets;
Worksheet worksheet = worksheets.Add("My Worksheet");
//Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = worksheet.PageSetup;
//Setting worksheet name at the left header
pageSetup.SetHeader(0, "&A");
//Setting current date and current time at the central header
//and changing the font of the header
pageSetup.SetHeader(1, "&\"Times New Roman,Bold\"&D-&T");
//Setting current file name at the right header and changing the font of the header
pageSetup.SetHeader(2, "&\"Times New Roman,Bold\"&12&F");
//Setting a string at the left footer and changing the font of the footer
pageSetup.SetFooter(0, "Hello World! &\"Courier New\"&14 123");
//Setting picture at the central footer
pageSetup.SetFooter(1, "&G");
workbook.Save("../../data/headerfooter.xlsx");
NPOI - HSSF XSSF - Utilisation des en-têtes et pieds de page
C#
IWorkbook wb = new XSSFWorkbook();
ISheet sheet1 = wb.CreateSheet("First Sheet");
IHeader header = sheet1.Header;
header.Center = "Center Header";
header.Left = "Left Header";
header.Right = "Right Header";
FileStream sw = File.Create("../../data/header.xls");
wb.Write(sw);
sw.Close();
Télécharger le code d’exécution
TéléchargerUtilisation des en-têtes et pieds de page forment l’un des sites de codage social mentionnés ci-dessous :
Pour plus de détails, visitezTravailler avec des feuilles de calcul.