On this page you will learn from code samples for programming in C#.Writing of the code to add header and footer for spreadsheet with spreadsheet sdk in C# can be executed by programmers of any level using ByteScout Data Extraction Suite. ByteScout Data Extraction Suite: the set that includes 3 SDK products for data extraction from PDF, scans, images and from spreadsheets: PDF Extractor SDK, Data Extraction SDK, Barcode Reader SDK. It can add header and footer for spreadsheet with spreadsheet sdk in C#.
Want to quickly learn? This fast application programming interfaces of ByteScout Data Extraction Suite for C# plus the guidelines and the code below will help you quickly learn how to add header and footer for spreadsheet with spreadsheet sdk. IF you want to implement the functionality, just copy and paste this code for C# below into your code editor with your app, compile and run your application. Want to see how it works with your data then code testing will allow the function to be tested and work properly.
You can download free trial version of ByteScout Data Extraction Suite from our website with this and other source code samples for C#.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
using System;
using System.Diagnostics;
using System.IO;
using Bytescout.Spreadsheet;
namespace AddHeaderAndFooter
{
class Program
{
static void Main(string[] args)
{
try
{
// Create new Spreadsheet object
Spreadsheet spreadsheet = new Spreadsheet();
// Add new worksheet
Worksheet worksheet = spreadsheet.Workbook.Worksheets.Add("Sample");
// Add headers:
// add date as left header
worksheet.PageSetup.LeftHeader = "&D";
// add label with custom font as center header
worksheet.PageSetup.CenterHeader = "&\"Verdana,bold\"&14Laws && Rights";
// add time as right header
worksheet.PageSetup.RightHeader = "&T";
// Add footers:
// add file name as left footer
worksheet.PageSetup.LeftFooter = "&F";
// add "page of pages" indicator as center footer
worksheet.PageSetup.CenterFooter = "&P/&N";
// add simple text as right footer
worksheet.PageSetup.RightFooter = "Right footer";
// Add worksheet content
worksheet.Cell(1, 1).Value = "Click Print Preview to see headers and footers.";
// Save it as XLS
if (File.Exists("Output.xls"))
File.Delete("Output.xls");
spreadsheet.SaveAs("Output.xls");
// Close the document
spreadsheet.Close();
// Open output XLS file
Process.Start("Output.xls");
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.WriteLine("\nPress any key to exit...");
Console.ReadKey();
}
}
}
}
60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page
Explore ByteScout Data Extraction Suite Documentation
Explore Samples
Sign Up for ByteScout Data Extraction Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page
Explore ByteScout Data Extraction Suite Documentation
Explore Samples
Sign Up for ByteScout Data Extraction Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: