Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Spreadsheet .NET
>
Tutorial
> Set Print Area
The following example shows you how to set print area.
C# example
using System; using Independentsoft.Office; using Independentsoft.Office.Spreadsheet; namespace Sample { class Program { static void Main(string[] args) { Worksheet sheet1 = new Worksheet(); sheet1.ID = 1; sheet1.Name = "TestSheet1"; SheetView view1 = new SheetView(); view1.IsWorksheetTabSelected = true; view1.Index = 0; sheet1.Views.Add(view1); DefinedName range1 = new DefinedName("_xlnm.Print_Area"); range1.LocalSheetID = 0; range1.Body = "TestSheet1!$A$1:$B$20"; //print area Workbook book = new Workbook(); book.Sheets.Add(sheet1); book.DefinedNames.Add(range1); book.Save("c:\\test\\output.xlsx", true); } } }
VB example
Imports System Imports Independentsoft.Office Imports Independentsoft.Office.Spreadsheet Module Module1 Sub Main(ByVal args As String()) Dim sheet1 As New Worksheet() sheet1.ID = 1 sheet1.Name = "TestSheet1" Dim view1 As New SheetView() view1.IsWorksheetTabSelected = True view1.Index = 0 sheet1.Views.Add(view1) Dim range1 As New DefinedName("_xlnm.Print_Area") range1.LocalSheetID = 0 range1.Body = "TestSheet1!$A$1:$B$20" 'print area Dim book As New Workbook() book.Sheets.Add(sheet1) book.DefinedNames.Add(range1) book.Save("c:\test\output.xlsx", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*