Vous êtes sur la page 1sur 150

Copyright © 1987-2006 ComponentOne LLC. All rights reserved.

Corporate Headquarters
ComponentOne LLC
201 South Highland Avenue
3rd Floor
Pittsburgh, PA 15206 · USA

Internet: info@ComponentOne.com
Web site: http://www.componentone.com
Sales
E-mail: sales@componentone.com
Telephone: 1.800.858.2739 or 1.412.681.4343 (Pittsburgh, PA USA Office)

Technical Support
See Technical Support in this manual for information on obtaining technical support.

Trademarks
ComponentOne XLS for .NET and the ComponentOne XLS for .NET logo are trademarks, and ComponentOne is a registered
trademark of ComponentOne LLC. All other trademarks used herein are the properties of their respective owners.

Warranty
ComponentOne warrants that the original CD (or diskettes) are free from defects in material and workmanship, assuming normal use,
for a period of 90 days from the date of purchase. If a defect occurs during this time, you may return the defective CD (or disk) to
ComponentOne, along with a dated proof of purchase, and ComponentOne will replace it at no charge. After 90 days, you can obtain a
replacement for a defective CD (or disk) by sending it and a check for $25 (to cover postage and handling) to ComponentOne.
Except for the express warranty of the original CD (or disks) set forth here, ComponentOne makes no other warranties, express or
implied. Every attempt has been made to ensure that the information contained in this manual is correct as of the time it was written.
We are not responsible for any errors or omissions. ComponentOne’s liability is limited to the amount you paid for the product.
ComponentOne is not liable for any special, consequential, or other damages for any reason.

Copying and Distribution


While you are welcome to make backup copies of the software for your own use and protection, you are not permitted to make copies
for the use of anyone else. We put a lot of time and effort into creating this product, and we appreciate your support in seeing that it is
used by licensed users only. Please read End-User License Agreement forComponentOne Software and Redistributable Files sections
in this manual before copying and redistributing any ComponentOne XLS for .NET files.
· iii

Table of Contents
Table of Contents ................................................................................................................iii
Welcome to ComponentOne XLS for .NET ................................................................................ 1
What's New in ComponentOne XLS for .NET .......................................................................................1
Installing XLS for .NET.........................................................................................................................2
END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE..................................3
Licensing FAQs.....................................................................................................................................9
Redistributable Files ............................................................................................................................12
Technical Support................................................................................................................................12
Namespaces ........................................................................................................................................13
Adding a Reference to the C1Excel Assembly.......................................................................................14
Migrating a C1XLS Project to Visual Studio 2005.................................................................................15
Overview...........................................................................................................................19
Using C1XLS......................................................................................................................21
Creating Documents ............................................................................................................................21
Worksheets..........................................................................................................................................24
Rows and Columns..............................................................................................................................25
Cells....................................................................................................................................................25
Styles ..................................................................................................................................................25
C1XLS Samples...................................................................................................................27
C# Samples .........................................................................................................................................27
C1Excel Frequently Asked Questions .......................................................................................27
C1Excel Task-Based Help ......................................................................................................29
Adding Content to a Workbook ...........................................................................................................29
Formatting Cells ..................................................................................................................................30
Copying Rows from One Book to Another ...........................................................................................32
C1.C1Excel.2 Assembly ........................................................................................................35
C1.C1Excel Namespace ........................................................................................................35
C1.C1Excel Hierarchy .........................................................................................................................36
C1XLBook Class .................................................................................................................................37
XLAlignHorzEnum Enumeration ........................................................................................................44
XLAlignVertEnum Enumeration .........................................................................................................45
XLCell Class .......................................................................................................................................45
XLCellRange Class..............................................................................................................................49
XLCellRangeCollection Class ..............................................................................................................55
XLColumn Class .................................................................................................................................62
XLColumnCollection Class .................................................................................................................66
XLDiagonalFlags Enumeration............................................................................................................75
XLLineStyleEnum Enumeration ..........................................................................................................76
XLPatternEnum Enumeration .............................................................................................................76
XLPrintSettings Class ..........................................................................................................................78
XLRow Class ......................................................................................................................................89
XLRowCollection Class.......................................................................................................................92
XLSheet Class ................................................................................................................................... 102
XLSheetCollection Class.................................................................................................................... 112
XLStyle Class .................................................................................................................................... 125
Index .............................................................................................................................. 143
What's New in ComponentOne XLS for .NET · 1

Welcome to ComponentOne XLS for


.NET
Welcome to ComponentOne XLS™ for .NET. XLS for .NET (C1XLS) allows you to read and write
Microsoft Excel files from your applications.
ComponentOne has a user-friendly distribution policy. We want every programmer to obtain a copy of XLS
for .NET to try for as long as they wish. Those who like the product and find it useful may buy a license for a
reasonable price. The only restriction is that unlicensed copies of XLS for .NET will display a ComponentOne
banner every time they are loaded to remind developers to license the product.
We are confident that you will like XLS for .NET. If you have any suggestions or ideas for new features that
you'd like to see included in a future version, or ideas for new controls, please call us or write:

Corporate Headquarters
ComponentOne LLC
201 South Highland Avenue
3rd Floor
Pittsburgh, PA 15206 • USA
412.681.4343
412.681.4384 (Fax)
http://www.componentone.com

What's New in ComponentOne XLS for .NET


This documentation was last revised on September 28, 2005.

Feature Overview
Support has been added for external references, images, page breaks, filters, and conditional formatting. Like
formulas, these are read and saved, but not exposed through the object model. This support allows C1Excel to
load “template” books, make changes, and then save them back.
An extra check has been added to the WRITEACCESS reader to allow reading of poorly written files created
with Java Excel API v2.5.3.
XLS for .NET now writes MULRK records, which allows you to save smaller xls files. (Version:
1.1.20053.37)

Class Members
Below is the most recent member added to the C1.C1Excel component:
XLColumnCollection Class Description
XLColumnCollection.Frozen Property This property allows the creation of non-scrollable columns.

XLRowCollection Class Description


XLRowCollection.Frozen Property This property allows the creation of non-scrollable rows.
2 · Welcome to ComponentOne XLS for .NET

XLSheet Class Description


XLSheet.Clone Method This method can be used to create copies of “template” sheets.

Installing XLS for .NET


The following sections provide helpful information on installing XLS for .NET.

XLS for .NET Setup Files


The installation program will create the following directory: C:\Program Files\ComponentOne Studio.NET.
This directory contains the following subdirectories:
bin Contains copies of all binaries (DLLs, EXEs) in the ComponentOne Visual
Studio.NET package.
Common Contains support and data files that are used by many of the demo programs.
Help Contains online documentation for all Studio components.
C1Excel Contains samples and tutorials for the C1Excel component.

System Requirements
• Operating Systems:
- Windows 2000
- Windows 2003 Server
- Windows NT 4
- Windows XP, sp1, sp2
• Environments:
- .NET Framework 1.0
- .NET Framework1.1
- C# .NET
- Delphi
- Visual Basic .NET
• Environments (Visual Studio 2005):
- .NET Framework 2.0
- C# .NET
- Visual Basic .NET
• Hard Disk Space: 4 MB of hard disk space for storage of the software
• Disc Drive: CD or DVD-ROM drive if installing from CD

Installing Demonstration Versions


If you wish to try XLS for .NET or any of our other products and do not have a registration key, follow the
steps through the installation wizard and use the default serial number.
The only difference between unregistered (demonstration) and registered (purchased) versions of our products
is that registered versions will stamp every application you compile so a ComponentOne banner will not
appear when your users run the applications.
END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE · 3

Uninstalling XLS for .NET


To uninstall XLS for .NET, open the Control Panel and select the Add or Remove Programs. Select
ComponentOne XLS for .NET and click the Remove button.

END-USER LICENSE AGREEMENT FOR COMPONENTONE


SOFTWARE
IMPORTANT-READ CAREFULLY: This End User License Agreement (this "EULA") contains the terms
and conditions that govern your use of the SOFTWARE (as defined below) and imposes material limitations
to your rights. You should read this EULA carefully and treat it as valuable property.
I. THIS EULA.
1. Software Covered by this EULA. This EULA governs your use of the ComponentOne, LLC ("C1")
software product(s) enclosed or otherwise accompanied herewith (individually and collectively, the
"SOFTWARE"). The term "SOFTWARE" includes, to the extent provided by C1: 1) any revisions,
updates and/or upgrades thereto; 2) any data, image or executable files, databases, data engines, computer
software, or similar items customarily used or distributed with computer software products; 3) anything in
any form whatsoever intended to be used with or in conjunction with the SOFTWARE; and 4) any
associated media, documentation (including physical, electronic and online) and printed materials (the
"Documentation").
2. This EULA is a Legally Binding Agreement Between You and C1. If you are acting as an agent of a
company or another legal person, such as an officer or other employee acting for your employer, then
"you" and "your" mean your principal, the entity or other legal person for whom you are acting.
However, importantly, even if you are acting as an agent for another, you may still be personally liable for
violation of federal and State laws, such as copyright infringement.
By signifying your acceptance of the terms of this EULA, you intend to be, and hereby are, legally bound
to this EULA to the same extent as if C1 and you physically signed this EULA. By installing, copying, or
otherwise using the SOFTWARE, you agree to be bound by all the terms and conditions of this EULA. If
you do not agree to all of such terms and conditions, you may not install or use the SOFTWARE. If you
do not agree with any of the terms herewith and, for whatever reason, installation has begun or has been
completed, you should cancel installation or un-install the SOFTWARE, as the case may be.
Furthermore, you should promptly return the SOFTWARE to the place of business from which you
obtained it in accordance with any return policies of such place of business. Return policies may vary
among resellers; therefore you must comply with the return policies of your supplier as you agreed at the
point of purchase. If the place of business from which you purchased the SOFTWARE does not honor a
full refund for a period of thirty (30) days from the date of purchase, you may then return the
SOFTWARE directly to C1 for a refund provided that such returns is authorized within the same thirty
(30) days time period. To return the product directly to C1, you must first obtain a Return Authorization
Number by contacting C1, and you must forward to C1 all items purchased, including the proof of
purchase. The return must be postage-prepaid, and post-marked within thirty (30) days from the proof of
purchase, time being of the essence. The return option to C1 is only available to the original purchaser of
an unopened factory packaged item.
II. YOUR LICENSE TO DEVELOP AND TO DISTRIBUTE.
As provided in more detail below, this EULA grants you two licenses: 1) a license to use the SOFTWARE to
develop other software products (the "Development License"); and 2) a license to use and/or distribute the
Developed Software (the "Distribution License"). These licenses (individually and collectively, the
"Licenses") are explained and defined in more detail below.
1. Definitions. The following terms have the respective meanings as used in this EULA:
4 · Welcome to ComponentOne XLS for .NET

"Network Server" means a computer with one or more computer central processing units (CPU's) that
operates for the purpose of serving other computers logically or physically connected to it, including, but
not limited to, other computers connected to it on an internal network, intranet or the Internet.
"Web Server" means a type of Network Server that serves other computers which, are specifically
connected to it through either an intranet or the Internet.
"Developed Software" means those computer software products that are developed by or through the use
of the SOFTWARE.
"Developed Web Server Software" means those Developed Software products that reside logically or
physically on at least one Web Server and are operated (meaning the computer software instruction set is
carried out) by the Web Server's central processing unit(s) (CPU).
"Redistributable Files" means the SOFTWARE files or other portions of the SOFTWARE that are
provided by C1 and are identified as such in the Documentation for distribution by you with the
Developed Software.
"Developer" means a human being or any other automated device using the SOFTWARE in accordance
with the terms and conditions of this EULA.
"Developer Seat License" means that each Developer using or otherwise accessing the programmatic
interface or the SOFTWARE must obtain the right to do so by purchasing a separate End User License.
"Source Code" shall mean computer software code or programs in human readable format, such as a
printed listing of such a program written in a high-level computer language. The term "Source Code"
includes, but is not limited to, documents and materials in support of the development effort of the
SOFTWARE, such as flow charts, pseudo code and program notes.
2. Your Development License. You are hereby granted a limited, royalty-free, non-exclusive right to use
the SOFTWARE to design, develop, and test Developed Software, on the express condition that, and only
for so long as, you fully comply with all terms and conditions of this EULA.
The SOFTWARE is licensed to you on a Developer Seat License basis.
Developer Seat License basis means that you may perform an installation of the SOFTWARE for use in
designing, testing and creating Developed Software by a single Developer on one or more computers, each
with a single set of input devices, so long as 1) such computer/computers is/are used only by one single
Developer at any given time and not concurrently and, 2) the user is the primary User to whom the license
has been granted. Conversely, you may not install or use the SOFTWARE on a computer that is a
network server or a computer at which the SOFTWARE is used by more than one Developer. You may
not network the SOFTWARE or any component part of it, where it is or may be used by more than one
Developer unless you purchase an additional Development License for each Developer. You must
purchase another separate license to the SOFTWARE in order to add additional developer seats, whether
the additional developers are accessing the SOFTWARE in a stand-alone environment or on a computer
network.
The license rights granted under this Agreement may be limited to a specified number of days after you
first install the SOFTWARE unless you supply information required to license or verify your licensed
copy, as the case may be, within the time and the manner described during the SOFTWARE setup
sequence and/or in the dialog boxes appearing during use of the SOFTWARE. You may need to verify
the SOFTWARE through the use of the Internet, email or telephone; toll charges may apply. You may
need to re-verify the SOFTWARE if you modify your computer hardware. Product verification is based
on the exchange of information between your computer and C1. None of this information contains
personally identifiable information nor can they be used to identify any personal information about you or
any information you store in your computer. YOU ACKNOWLEDGE AND UNDERSTAND THAT
THERE ARE TECHNOLOGICAL MEASURES IN THE SOFTWARE THAT ARE DESIGNED TO
PREVENT UNLICENSED OR ILLEGAL USE OF THE SOFTWARE. YOU AGREE THAT C1
MAY USE SUCH MEASURES AND YOU AGREE TO FOLLOW ANY REQUIREMENTS
REGARDING SUCH TECHNOLOGICAL MEASURES. YOU ACKNOWLEDGE AND AGREE
END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE · 5

THAT THE SOFTWARE WILL CEASE TO FUNCTION UNLESS AND UNTIL YOU VERIFY
THE APPLICABLE SOFTWARE SERIAL KEY.
You agree that C1 may audit your use of the SOFTWARE for compliance with these terms at any time,
upon reasonable notice. In the event that such audit reveals any use of the SOFTWARE other than in full
compliance with the terms of this EULA, you shall reimburse C1 for all reasonable expenses related to
such audit in addition to any other liabilities you may incur as a result of such non-compliance.
In all cases, (a) you may not use C1's name, logo, or trademarks to market your Developed Software
without the express written consent of C1; (b) you must include the following C1 copyright notice in your
Developed Software documentation and/or in the "About Box" of your Developed Software, and
wherever the copyright/rights notice is located in the Developed Software (“Portions Copyright ©
ComponentOne, LLC 1991-2005. All Rights Reserved.”); (c) you agree to indemnify, hold harmless, and
defend C1, its suppliers and resellers, from and against any claims or lawsuits, including attorney's fees
that may arise from the use or distribution of your Developed Software; (d) you may use the SOFTWARE
only to create Developed Software that is significantly different than the SOFTWARE.
3. Your Distribution License.
License to Distribute Developed Software. Subject to the terms and conditions in this EULA, you are
granted the license to use and to distribute Developed Software on a royalty-free basis, provided that the
Developed Software incorporates the SOFTWARE as an integral part of the Developed Software in
machine-language compiled format (customarily an ".exe", or ".dll", etc.). You may not distribute,
bundle, wrap or subclass the SOFTWARE as Developed Software which, when used in a "designtime"
development environment, exposes the programmatic interface of the SOFTWARE. You may distribute,
on a royalty-free basis, Redistributable Files with Developed Software only. You may not add or transfer
the SOFTWARE license key to the computer where the Developed Software is installed. Users of the
Developed Software may not use the SOFTWARE or the Redistributable Files, directly or indirectly, for
development purposes. In particular, if you create a control (or user control) using the SOFTWARE as a
constituent control, you are not licensed to distribute the control you created with the SOFTWARE to
users for development purposes.
4. Specific Product Limitations. Notwithstanding anything in this EULA to the contrary, if the license you
have purchased is for any of the following products, then the following additional limitations will apply:
a. ComponentOne Reports for .NET Designer Edition. ComponentOne Reports for .NET Designer
Edition includes at least: 1) one dynamic link library file (c1.win.c1reportdesigner.dll) known as
C1ReportDesigner Component, 2) one executable file (ReportDesigner.exe) known as C1ReportDesigner
Application and, 3) the Source Code of the C1ReportDesigner Application. The C1ReportDesigner
Component is subject to the general terms and restrictions set forth in this EULA. The C1ReportDesigner
Application is an executable file used to design and prepare reports; the C1ReportDesigner Application
may be distributed, free of royalties, only in conjunction with the Developed Software.
C1 hereby also grants you the right to use and to modify the C1ReportDesigner Application Source Code
to create derivative works that are based on the licensed Source Code. You may distribute such derivative
works, solely in object code format and exclusively in conjunction with and/or as a part of the Developed
Software. You are expressly not granted the right to distribute, disclose or otherwise make available to
any third party the licensed Source Code, any portion, modified version or derivative work thereof, in
source code format.
C1 shall retain all right, title and interest in and to the licensed Source Code, and all C1 updates,
modifications or enhancements thereof. Nothing herein shall be deemed to transfer any ownership or title
rights in and to the licensed Source Code from C1 to you.
SOURCE CODE IS LICENSED TO YOU AS IS. C1 DOES NOT AND SHALL NOT PROVIDE YOU
WITH ANY TECHNICAL SUPPORT FOR YOUR SOURCE CODE LICENSE.
b. VSView Reporting Edition (ActiveX). VSView Reporting Edition includes at least one executable file
listed as “VSRptX.exe” (where X indicates the version number i.e.7,8, etc.), known as “Designer.” The
6 · Welcome to ComponentOne XLS for .NET

file "VSRptX.exe”, or any upgrade or future versions of the Designer, are subject to the restrictions set
forth in this EULA and may not be distributed with your Developed Software or in any other way.
c. Studio Products. You may not share the component parts of the Studio Products licensed to you with
other Developers, nor may you allow the use and/or installation of such components by other Developers.
5. Updates/Upgrades; Studio Subscription. Subject to the terms and conditions of this EULA, the Licenses
are perpetual. Updates and upgrades to the SOFTWARE may be provided by C1 from time-to-time, and,
if so provided by C1, are provided upon the terms and conditions offered at that time by C1 in its sole
discretion. C1 may provide updates and upgrades to the SOFTWARE for free or for any charge, at any
time or never, and through its chosen manner of access and distribution, all in C1's sole discretion.
C1 licenses certain of its separately-licensed products bundled together in a product suite, called the C1
"Studio" product line (the "Studio Products"). The exact separately-licensed products that are bundled
into the Studio Products may change from time-to-time in C1's sole discretion. If the SOFTWARE is
identified as a C1 "Studio" product, then the SOFTWARE is one of the Studio Products. The
SOFTWARE and the Studio Products are revised from time-to-time (meaning, for example, revised with
updates, upgrades and, in the case of Studio products, some times changes to the mix of products included
in the bundle). To receive any such revisions to the SOFTWARE or the Studio Products, as the case may
be, you must have a valid SOFTWARE license or a valid Studio subscription. Together with the
Licenses, the original purchaser is granted a one-year subscription from the date of purchase. Upon
expiration, you must renew your license subscription to continue to be entitled to receive SOFTWARE
and/or the Studio Products revisions as the case may be.
6. Serial Number. With your license, you will be issued a unique serial number (the "Serial Number") used
for the activation of the SOFTWARE. The Serial Number is subject to the restrictions set forth in this
EULA and may not be disclosed or distributed either with your Developed Software or in any other way.
The disclosure or distribution of the Serial Number constitutes a breach of this EULA, the effect of which
shall be the immediate termination and revocation of all the rights granted herein.
7. Evaluation Copy. If you are using an "evaluation copy", specifically designated as such by C1 on its
website or elsewhere, then the Licenses are limited as follows: a) you are granted a license to use the
SOFTWARE for a period of thirty (30) days counted from the day of installation (the "Evaluation
Period"); b) upon completion of the Evaluation Period, you shall either i) delete the SOFTWARE from
the computer containing the installation, or you may ii) obtain a paid license of the SOFTWARE from C1
or any of its resellers; and c) any Developed Software developed with the Evaluation Copy may not be
distributed or used for any commercial purpose.
III. INTELLECTUAL PROPERTY.
1. Copyright. You agree that all right, title, and interest in and to the SOFTWARE (including, but not
limited to, any images, photographs, animations, video, audio, music, text, and “applets” incorporated
into the SOFTWARE), and any copies of the SOFTWARE, and any copyrights and other intellectual
properties therein or related thereto are owned exclusively by C1, except to the limited extent that C1 may
be the rightful license holder of certain third-party technologies incorporated into the SOFTWARE. The
SOFTWARE is protected by copyright laws and international treaty provisions. The SOFTWARE is
licensed to you, not sold to you. C1 reserves all rights not otherwise expressly and specifically granted to
you in this EULA.
2. Backups. You may make a copy of the SOFTWARE solely for backup or archival purposes.
Notwithstanding the foregoing, you may not copy the printed Documentation.
3. General Limitations. You may not reverse engineer, decompile, or disassemble the SOFTWARE, except
and only to the extent that applicable law expressly permits such activity notwithstanding this limitation.
4. Software Transfers. You may not rent or lease the SOFTWARE. You may permanently transfer all of
your rights under the EULA, provided that you retain no copies, that you transfer all the SOFTWARE
(including all component parts, the media and printed materials, any updates, upgrades, this EULA and, if
applicable, the Certificate of Authenticity), and that the transferee agrees to be bound by the terms of this
END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE · 7

EULA. If the SOFTWARE is an update or upgrade, any transfer must include all prior versions of the
SOFTWARE.
5. Termination. Without prejudice to any other rights it may have, C1 may terminate this EULA and the
Licenses if you fail to comply with the terms and conditions contained herein. In such an event, you must
destroy all copies of the SOFTWARE and all of its component parts.
6. Export Restrictions. You acknowledge that the SOFTWARE is of U.S. origin. You acknowledge that the
license and distribution of the SOFTWARE is subject to the export control laws and regulations of the
United States of America, and any amendments thereof, which restrict exports and re-exports of software,
technical data, and direct products of technical data, including services and Developed Software. You
agree that you will not export or re-export the SOFTWARE or any Developed Software, or any
information, documentation and/or printed materials related thereto, directly or indirectly, without first
obtaining permission to do so as required from the United States of America Department of Commerce's
Bureau of Export Administration ("BXA"), or other appropriate governmental agencies, to any countries,
end-users, or for any end-uses that are restricted by U.S. export laws and regulations, and any
amendments thereof, which include, but are not limited to: Restricted Countries, Restricted End-Users,
and Restricted End-Uses.
These restrictions change from time to time. You represent and warrant that neither the BXA nor any
other United States federal agency has suspended, revoked or denied your export privileges. C1
acknowledges that it shall use reasonable efforts to supply you with all reasonably necessary information
regarding the SOFTWARE and its business to enable you to fully comply with the provisions of this
Section. If you have any questions regarding your obligations under United States of America export
regulations, you should contact the Bureau of Export Administration, United States Department of
Commerce, Exporter Counseling Division, Washington DC. U.S.A. (202) 482-4811,
http://www.bxa.doc.gov.
7. U.S. Government Restricted Rights. The SOFTWARE and documentation are provided with
RESTRICTED RIGHTS. You will comply with any requirements of the Government to obtain such
RESTRICTED RIGHTS protection, including without limitation, the placement of any restrictive legends
on the SOFTWARE, and any license agreement used in connection with the distribution of the
SOFTWARE. Manufacturer is ComponentOne, LLC, 201 South Highland Avenue , 3rd Floor, Pittsburgh,
Pennsylvania 15206 USA. For solicitations issued by the Government on or after December 1, 1995 and
the Department of Defense on or after September 29, 1995, the only rights provided in the software and
documentation provided herein shall be those contained in this EULA. Under no circumstances shall C1
be obligated to comply with any Governmental requirements regarding the submission of or the request
for exemption from submission of cost or pricing data or cost accounting requirements. For any
distribution of the SOFTWARE that would require compliance by C1 with the Government's
requirements relating to cost or pricing data or cost accounting requirements, you must obtain an
appropriate waiver or exemption from such requirements for the benefit of C1 from the appropriate
Government authority before the distribution and/or license of the SOFTWARE to the Government.
IV. WARRANTIES AND REMEDIES.
1. Limited Warranty. C1 warrants that the original media, if any, are free from defects for ninety (90) days
from the date of delivery of the SOFTWARE. C1 also warrants that: (i) it has the full power to enter into
this Agreement and grant the license rights set forth herein; (ii) it has not granted and will not grant any
rights in the Software to any third party which grant is inconsistent with the rights granted to you in this
Agreement; and (iii) the Software does not and will not infringe any trade secret, copyright, trademark or
other proprietary right held by any third party and does not infringe any patent held by any third party.
EXCEPT AS OTHERWISE PROVIDED IN THE PRECEDING SENTENCE, AND TO THE
MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, C1 EXPRESSLY DISCLAIMS ANY
WARRANTY FOR THE SOFTWARE, DOCUMENTATION AND ANYTHING ELSE
PROVIDED BY C1 HEREBY AND C1 PROVIDES THE SAME IN “AS IS” CONDITION
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF USE OR
8 · Welcome to ComponentOne XLS for .NET

PERFORMANCE OF THE SOFTWARE AND DOCUMENTATION REMAINS WITH YOU.


THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS. YOU MAY HAVE
OTHERS WHICH VARY FROM STATE TO STATE.
2. Limited Remedy. C1 PROVIDES NO REMEDIES OR WARRANTIES, WHETHER EXPRESS OR
IMPLIED, FOR ANY SAMPLE APPLICATION CODE, REDISTRIBUTABLE FILES, TRIAL
VERSION AND THE NOT FOR RESALE VERSION OF THE SOFTWARE. ANY SAMPLE
APPLICATION CODE, TRIAL VERSION AND THE NOT FOR RESALE VERSION OF THE
SOFTWARE ARE PROVIDED “AS IS”.
C1's entire liability and your exclusive remedy under this EULA shall be, at C1's sole option, either (a)
return of the price paid for the SOFTWARE; (b) repair the SOFTWARE through updates distributed
online or otherwise in C1's discretion; or (c) replace the SOFTWARE with SOFTWARE that
substantially performs as described in the SOFTWARE documentation, provided that you return the
SOFTWARE in the same manner as provided in Section I.2 for return of the SOFTWARE for non-
acceptance of this EULA. Any media for any repaired or replacement SOFTWARE will be warranted for
the remainder of the original warranty period or thirty (30) days, whichever is longer. THESE
REMEDIES ARE NOT AVAILABLE OUTSIDE OF THE UNITED STATES OF AMERICA. TO
THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL C1 BE
LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
DAMAGES FOR LOSS OF BUSINESS PROFIT, BUSINESS INTERRUPTION, LOSS OF
BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE
USE OR INABILITY TO USE THE SOFTWARE, EVEN IF C1 HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES/JURISDICTIONS DO NOT
ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR
INCIDENTAL DAMAGES IN CERTAIN CASES, THE ABOVE LIMITATION MAY NOT APPLY
TO YOU.
V. MISCELLANEOUS.
1. This is the Entire Agreement. This EULA (including any addendum to this EULA included with the
SOFTWARE) is the final, complete and exclusive statement of the entire agreement between you and C1
relating to the SOFTWARE. This EULA supersedes any prior and contemporaneous proposals, purchase
orders, advertisements, and all other communications in relation to the subject matter of this EULA,
whether oral or written. No terms or conditions, other than those contained herein, and no other
understanding or agreement which in any way modifies these terms and conditions, shall be binding upon
the parties unless entered into in writing executed between the parties, or by other non-oral manner of
agreement whereby the parties objectively and definitively act in a manner to be bound (such as by
continuing with an installation of the SOFTWARE, etc.). Employees, agents and other representatives of
C1 are not permitted to orally modify this EULA.
2. You Indemnify C1. You agree to indemnify, hold harmless, and defend C1 and its suppliers and resellers
from and against any and all claims or lawsuits, including attorney's fees, which arise out of or result from
your distribution of your Developed Software, your Developed Web Server Software or from your breach
of any of the terms and conditions of this EULA.
3. Interpretation of this EULA. If for any reason a court of competent jurisdiction finds any provision of
this EULA, or any portion thereof, to be unenforceable, that provision of this EULA will be enforced to
the maximum extent permissible so as to effect the intent of the parties, and the remainder of this EULA
will continue in full force and effect. Formatives of defined terms shall have the same meaning of the
defined term. Failure by either party to enforce any provision of this EULA will not be deemed a waiver
of future enforcement of that or any other provision. Except as otherwise required or superseded by law,
this EULA is governed by the laws of the Commonwealth of Pennsylvania, without regard to its conflict
of laws principles. The parties consent to the personal jurisdiction and venue of the Commonwealth of
Pennsylvania, in the County of Allegheny, and agree that any legal proceedings arising out of this EULA
shall be conducted solely in such Commonwealth. If the SOFTWARE was acquired outside the United
States, then local law may apply.
Licensing FAQs · 9

Licensing FAQs
This section describes the main technical aspects of licensing. It may help the user to understand and resolve
licensing problems he may experience when using ComponentOne .NET and ASP.NET products.

What is Licensing?
Licensing is a mechanism used to protect intellectual property by ensuring that users are authorized to use
software products.
Licensing is not only used to prevent illegal distribution of software products. Many software vendors,
including ComponentOne, use licensing to allow potential users to test products before they decide to purchase
them.
Without licensing, this type of distribution would not be practical for the vendor or convenient for the user.
Vendors would either have to distribute evaluation software with limited functionality, or shift the burden of
managing software licenses to customers, who could easily forget that the software being used is an evaluation
version and has not been purchased.

How does Licensing Work?


ComponentOne uses a licensing model based on the standard set by Microsoft, which works with all types of
components.
NOTE: The Compact Framework components use a slightly different mechanism for licensing than the other
ComponentOne components due to platform differences.
When a user decides to purchase a product, he receives an installation program and a Serial Number. During
the installation process, the user is prompted for the serial number that is saved on the system. (Users can also
enter the serial number by clicking the "License" button on the About Box of any ComponentOne product.)
When a licensed component is added to a form or web page, Visual Studio asks the newly created component
for licensing information. The component looks for licensing information stored in the system and generates a
key, which Visual Studio saves in two files:
1. a "<projectName>.licenses" resource file which contains the actual key and
2. a "licenses.licx" file that contains references to those resources.
These files are automatically added to the project.
Note that the licenses.licx file is usually not shown in the Solution Explorer; it appears if you press the "Show
All Files" button in the Solution Explorer's toolbox, or select "Project | Show All Files" from Visual Studio's
main menu.
Later, when the component is created at run time, it gets passed the key that was created at design time and
can decide whether to simply accept the key, to throw an exception and fail altogether, or to display some
information reminding the user that the software has not been licensed.
All ComponentOne products are designed to display licensing information if the product is not licensed. None
will throw licensing exceptions and prevent applications from running.

Common Scenarios

Creating components at design time


This is the most common scenario and also the simplest: the user adds one or more controls to the form, the
licensing information is stored in the licenses.licx file, and the component works.
Note that the mechanism is exactly the same for Windows Forms and Web Forms (ASP.NET) projects.
10 · Welcome to ComponentOne XLS for .NET

Creating components at run time


This is also a fairly common scenario. You do not need an instance of the component on the form, but would
like to create one or more instances at run time.
In this case, the project will not contain a licenses.licx file (or the file will not contain an appropriate key for
the component) and therefore licensing will fail.
To fix this problem, add an instance of the component to a form in the project. This will create the licenses.licx
file and things will then work as expected. (The component can be removed from the form after the
licenses.licx file has been created).

Inheriting from licensed components


If a component that inherits from a licensed component is created, the licensing information to be stored in the
form is still needed. This can be done in two ways:
• Add a LicenseProvider attribute to the component.
This will mark the component as licensed. When a component is added to a form, Visual Studio
will create and manage the licenses.licx file, and the base class will handle the licensing process as
usual. No additional work is needed. For example:
[LicenseProvider(typeof(LicenseProvider))]
class MyGrid: C1.Win.C1FlexGrid.C1FlexGrid
{
// ...
}
• Add an instance of the base component to the form.
This will embed the licensing information into the licenses.licx file as in the previous scenario, and
the base component will find it and use it. As before, the extra instance can be deleted after the
licenses.licx file has been created.

Using licensed components in console applications


When building console applications, there are no forms to add components to, and therefore Visual Studio
won't create a licenses.licx file.
In these cases, create a temporary Windows Forms application and add all the desired licensed components to
a form. Then close the Windows Forms application and copy the licenses.licx file into the console application
project.
Make sure the licensex.licx file is configured as an embedded resource. To do this, right-click the licenses.licx
file in the Solution Explorer window and select Properties. In the property window, set the "Build Action"
property to "Embedded Resource".

Using licensed components in Visual C++ applications


It seems there is a bug in VC++ 2003. The licenses.licx is ignored during the build process, therefore the
licensing information is not included in VC++ applications.
To fix this problem, extra steps must be taken to compile the licensing resources and link them to the project.
Note the following:
1. Build the C++ project as usual. This should create an exe file and also a licenses.licx file with
licensing information in it.
2. Copy the licenses.licx file from the app directory to the target folder (Debug or Release).
3. Copy the C1Lc.exe utility and the licensed dlls to the target folder. (Don't use the standard lc.exe, it
has bugs.)
Licensing FAQs · 11

4. Use C1Lc.exe to compile the licenses.licx file. The command line should look like this:
c1lc /target:MyApp.exe /complist:licenses.licx /i:C1.Win.C1FlexGrid.dll
5. Link the licenses into the project. To do this, go back to Visual Studio, right-click the project, select
properties, and go to the Linker/Command Line option. Enter the following:
/ASSEMBLYRESOURCE:Debug\MyApp.exe.licenses
6. Rebuild the executable to include the licensing information in the application.

Troubleshooting
We try very hard to make the licensing mechanism as unobtrusive as possible, but problems may occur for a
number of reasons.
Below is a description of the most common problems and their solutions.

I have a licensed version of a ComponentOne product but I still get the splash screen when I run my
project.
If this happens, there must be a problem with the licenses.licx file in the project. It either doesn't exist, contains
wrong information, or is not configured correctly.
First, try a full rebuild ("Rebuild All" from the Visual Studio Build menu). This will usually rebuild the correct
licensing resources.
If that fails, follow these steps:
1. Open the project and go to the Solution Explorer window.
2. Click the "Show All Files" button on the top of the window.
3. Find the licenses.licx file and delete it.
4. Close the project and reopen it.
5. Open the main form and add an instance of each licensed control.
6. Check the Solution Explorer window, there should be a licenses.licx file there.
7. Rebuild the project using the "Rebuild All" option (not just "Rebuild").

I have a licensed version of a ComponentOne product on my web server but the components still
behave as unlicensed.
There is no need to install any licenses on machines used as servers and not used for development.
The components must be licensed on the development machine, therefore the licensing information will be
saved into the executable (exe or dll) when the project is built. After that, the application can be deployed on
any machine, including web servers.

I downloaded a new build of a component that I have purchased, and now I'm getting the splash screen
when I build my projects.
Make sure that the license key is still valid. If you licensed the component over a year ago, your subscription
may have expired. In this case, you have two options:
Option 1 - Renew your subscription to get a new license key.
If you choose this option, you will receive a new key that you can use to license the new components (from the
installation utility or directly from the About Box).
The new subscription will entitle you to a full year of upgrades and to download the latest maintenance builds
directly from http://prerelease.componentone.com/.
12 · Welcome to ComponentOne XLS for .NET

Option 2 – Continue to use the components you have.


Subscriptions expire, products do not. You can continue to use the components you received or downloaded
while your subscription was valid.

Redistributable Files
ComponentOne XLS for .NET is developed and published by ComponentOne LLC. You may use it to
develop applications in conjunction with Microsoft Visual Studio or any other programming environment that
enables the user to use and integrate the control(s). You may also distribute, free of royalties, the following
Redistributable Files with any such application you develop to the extent that they are used separately on a
single CPU on the client/workstation side of the network:
• C1.C1Excel.dll
• C1.C1Excel.2.dll (if using Visual Studio 2005)
Site licenses are available for groups of multiple developers. Please contact Sales@ComponentOne.com for
details.

Technical Support
XLS for .NET is developed and supported by ComponentOne LLC, a company formed by the merger of
APEX Software Corporation and VideoSoft. You can obtain technical support using any of the following
methods:

ComponentOne Web Site


The ComponentOne Web site at www.componentone.com provides a wealth of information and software
downloads for XLS for .NET users, including:
• Descriptions of the various support options available through the ComponentOne Service Team.
• Answers to frequently asked questions (FAQ's) about our products, organized by functionality. Please
consult the FAQ's before contacting us directly, as this can save you time and also introduce you to
other useful information pertaining to our products.
• Free product updates, which provide you with bug fixes and new features.

ComponentOne HelpCentral
ComponentOne HelpCentral is the new online resource for Visual Studio developers and Help authors. Visit
HelpCentral to get information on ComponentOne products, view online demos, get Tech Tips and answers to
frequently asked questions (FAQ's), search the ComponentOne knowledgebase and more!

Internet e-mail
For technical support through the Internet, e-mail us at:
support.c1excel.net@componentone.com
To help us provide you with the best support, please include the following information when contacting
ComponentOne:
• Your ComponentOne product serial number.
• The version and name of your operating system.
• Your development environment and its version.
For more information on technical support, go to www.componentone.com/support.
Namespaces · 13

Peer-to-Peer newsgroup
ComponentOne also sponsors peer-to-peer newsgroups for users. ComponentOne does not offer formal
technical support in this newsgroup, but instead sponsors it as a forum for users to post and answer each
other's questions regarding our products. However, ComponentOne may monitor the newsgroups to ensure
accuracy of information and provide comments when necessary. You can access the newsgroup from the
ComponentOne Web site at http://helpcentral.componentone.com/Newsgroups.aspx.

Documentation
ComponentOne documentation is available with each of our products in HTML Help, Microsoft Help 2.0
(.NET, ASP.NET and Mobile Device products only), and PDF format. All of the PDFs are also available on
HelpCentral. If you have suggestions on how we can improve our documentation, please email the
Documentation team. Please note that e-mail sent to the Documentation team is for documentation feedback
only. Technical Support and Sales issues should be sent directly to their respective departments.

Namespaces
Namespaces organize the objects defined in an assembly. Assemblies can contain multiple namespaces, which
can in turn contain other namespaces. Namespaces prevent ambiguity and simplify references when using
large groups of objects such as class libraries.
The namespace for the C1Excel component is C1.C1Excel. The following code fragment shows how to
declare a C1Excel component using the fully qualified name for this class:
• Visual Basic
Dim xlbook1 As C1.C1Excel.C1XLBook
• C#
C1.C1Excel.C1XLBook xlbook1;
• Delphi
var
xlbook1: C1.C1Excel.C1XLBook;
Namespaces address a problem sometimes known as namespace pollution, in which the developer of a class
library is hampered by the use of similar names in another library. These conflicts with existing components
are sometimes called name collisions.
For example, if you create a new class named XLSheet, you can use it inside your project without
qualification. However, the C1Excel assembly also implements a class called XLSheet. So, if you want to use
the C1Excel class in the same project, you must use a fully qualified reference to make the reference unique. If
the reference is not unique, Visual Studio .NET produces an error stating that the name is ambiguous. The
following code snippet demonstrates how to declare these objects:
• Visual Basic
' Define a new XLSheet object (custom XLSheet class)
Dim MyXLSheet as XLSheet
' Define a new C1Excel.XLSheet object.
Dim XLSheet as C1.C1Excel.XLSheet
• C#
// Define a new XLSheet object (custom XLSheet class)
XLSheet MyXLSheet;
// Define a new C1Excel.XLSheet object.
C1.C1Excel.XLSheet XLSheet;
14 · Welcome to ComponentOne XLS for .NET

• Delphi
var
MyXLSheet: C1.C1Excel.XLSheet;
MyXLSheet: XLSheet;
begin
MyXLSheet := XLSheet.Create;
MyXLSheet := C1.C1Excel.XLSheet.Create;
end;
Fully qualified names are object references that are prefixed with the name of the namespace where the object
is defined. You can use objects defined in other projects if you create a reference to the class (by choosing Add
Reference from the Project menu) and then use the fully qualified name for the object in your code.
Fully qualified names prevent naming conflicts because the compiler can always determine which object is
being used. However, the names themselves can get long and cumbersome. To get around this, you can use
the Imports statement (using in C#) to define an alias — an abbreviated name you can use in place of a fully
qualified name. For example, the following code snippet creates aliases for two fully qualified names, and uses
these aliases to define two objects:
• Visual Basic
Imports C1XLSheet = C1.C1Excel.XLSheet
Imports MyXLSheet = MyProject.XLSheet

Dim s1 As C1XLSheet
Dim s2 As MyXLSheet
• C#
using C1XLSheet = C1.C1Excel.XLSheet;
using MyXLSheet = MyProject.XLSheet;

C1XLSheet s1;
MyXLSheet s2;
• Delphi
uses
C1XLSheet, MyXLSheet;
var
s2: MyXLSheet;
s1: C1XLSheet;
begin
C1XLSheet := C1.C1Excel.XLSheet;
MyXLSheet := MyProject.XLSheet;
end;
If you use the Imports statement without an alias, you can use all the names in that namespace without
qualification, provided they are unique to the project.

Adding a Reference to the C1Excel Assembly


When you install XLS for .NET, a new component does not appear in the Visual Studio’s toolbox. Therefore,
to use C1XLS, you must reference the C1Excel assembly in your project. To use the C1Excel component:
1. Select the Add Reference option from the Project menu of your project.
2. Select the C1.C1Excel assembly from the list, or browse to find the C1.C1Excel.dll (or C1.C1Excel.2.dll if
using Visual Studio 2005) file.
Migrating a C1XLS Project to Visual Studio 2005 · 15

3. Double-click the form caption area to open the code window. At the top of the file, add the following
Imports statements (using in C#; uses in Delphi):
Imports System.IO
Imports C1.C1Excel
NOTE: This makes the objects defined in the C1Excel and System.IO assemblies visible to the project and
saves a lot of typing.

Migrating a C1XLS Project to Visual Studio 2005


To migrate a project using ComponentOne components to Visual Studio 2005, there are two main steps that
must be performed. First, you must convert your project to Visual Studio 2005, which includes removing any
references to a previous assembly and adding a reference to the new assembly. Secondly, the .licx file, or
licensing file, must be updated in order for the project to run correctly.
To convert the project:
1. Open Visual Studio 2005 and select File, Open Project.
2. Locate the .sln file for the project that you wish to convert to Visual Studio 2005. Select it and click Open.
The Visual Studio Conversion Wizard appears.

3. Click Next.
4. Select Yes, create a backup before converting to create a backup of your current project and click Next.
16 · Welcome to ComponentOne XLS for .NET

5. Click Finish to convert your project to Visual Studio 2005. The Conversion Complete window appears.
6. Click Show the conversion log when the wizard is closed if you want to view the conversion log.

7. Click Close. The project opens. Now you must remove references to any of the previous ComponentOne
.dlls and add references to the new ones.
8. Go to the Solution Explorer (View | Solution Explorer), select the project, and click the Show All Files
button.
Note: The Show All Files button does not appear in the Solution Explorer toolbar if the Solution project
node is selected.
Migrating a C1XLS Project to Visual Studio 2005 · 17

9. Expand the References node, right-click C1.Common and select Remove. Also remove c1.c1excel the
same way.
10. Right-click the References node and select Add Reference.
11. Browse and select C1.C1Excel.2.dll. Click OK to add it to the project.
To update the .licx file:
1. In the Solution Explorer, right-click the licenses.licx file and select Delete.
18 · Welcome to ComponentOne XLS for .NET

2. Click OK to permanently delete licenses.licx. The project must be rebuilt to create a new, updated version
of the .licx file.
3. Click the Start Debugging button to compile and run the project. The new .licx file may not be visible in
the Solution Explorer.
4. Select File, Close to close the form and then double-click the Form.vb or Form.cs file in the Solution
Explorer to reopen it. The new licenses.licx file appears in the list of files.

The migration process is complete.


Overview · 19

Overview
C1Excel is a library that allows you to read and write Microsoft Excel files from your applications.
C1XLS reads and writes Microsoft Excel files using the BIFF8 format used since Excel 8.0 (also known as
Excel 97).
The main use for C1XLS is to create XLS files that can be opened with Microsoft Excel. For example, the
C1Report component uses C1Excel to export reports to the XLS format, so they can be viewed and edited by
anyone with a copy of Microsoft Excel.
C1XLS can load files with multiple worksheets, including all cell content and formatting. However, it does not
recognize all elements saved by Microsoft Excel. The main limitations in the current version are (some of these
features will probably be added in future versions):
• Cell Borders: C1XLS does not currently expose cell borders.
• Formulas: C1XLS will read the last result of any calculations in the book, but it will not read or save
cell formulas.
• Images: C1XLS does not read or write images of any kind, including charts.
• Hyperlinks: C1XLS will read the content and style of cells that contain hyperlinks, but not the
hyperlinks themselves.
The main feature in C1XLS is ease of use. You can load a workbook with a single command, manipulate
sheets as if they were grid controls (composed of rows, columns, and cells), then save the workbook to an XLS
file.
Creating Documents · 21

Using C1XLS
Creating Documents
To create a new XLS file using C1XLS, three steps are required:
1. Create a C1XLBook object. Each book is composed of one or more sheets (XLSheet objects).
2. Add content to the sheets. Each sheet contains cells (XLCell objects) that have a Value and a Style
property.
3. Save the book to a file using the Save method.
For example, the following code creates a new Excel file with a single sheet containing numbers from 1 to
100:
• Visual Basic
' step 1: create a new workbook
Dim book As New C1XLBook()
' step 2: write content into some cells
Dim sheet As XLSheet = book.Sheets(0)
Dim i As Integer
For i = 0 To 99
sheet(i, 0).Value = i + 1
Next i
' step 3: save the file
book.Save("c:\temp\hello.xls")
• C#
// step 1: create a new workbook
C1XLBook book = new C1XLBook();

// step 2: write content into some cells


XLSheet sheet = book.Sheets[0];
for (int i = 0; i < 100; i++)
sheet[i, 0].Value = i + 1;
// step 3: save the file
book.Save(@"c:\temp\hello.xls");
• Delphi
var
book: C1XLBook;
sheet: XLSheet;
i: Integer;
begin
// step 1: create a new workbook
book := C1XLBook.Create;

// step 2: write content into some cells


sheet := book.Sheets[0];
for i = 0 to 99 do
sheet[i, 0].Value := i + 1;
// step 3: save the file
book.Save('c:\temp\hello.xls');
end;
22 · Using C1XLS

Step 2 is the most interesting one. The code starts by retrieving an XLSheet object that represents the single
worksheet in the new Excel workbook. This sheet is created automatically when you create a new C1XLBook.
Then the code uses the sheet indexer to reference cells in the sheet and assign them values from 1 to 100.
Note that the indexer in the XLSheet object automatically creates cells, if necessary. This makes it easy to fill
worksheets that you create. If you want to find out the sheet dimensions, use the sheet's Rows.Count and
Columns.Count properties.
Of course, you are not limited to assigning values to cells. You can also use styles to format the cells. Just
create one or more XLStyle objects and assign them to cells much like you did values. This revised version of
the code above creates a sheet where even numbers are shown in bold red characters and odd numbers in italic
blue:
• Visual Basic
' step 1: create a new workbook
Dim book As New C1XLBook()

' step 2: create styles for odd and even values


Dim styleOdd As New XLStyle(book)
styleOdd.Font = New Font("Tahoma", 9, FontStyle.Italic)
styleOdd.ForeColor = Color.Blue
Dim styleEven As New XLStyle(book)
styleEven.Font = New Font("Tahoma", 9, FontStyle.Bold)
styleEven.ForeColor = Color.Red

' step 3: write content and styles into some cells


Dim sheet As XLSheet = book.Sheets(0)
Dim i As Integer
For i = 0 To 99
Dim cell As XLCell = sheet(i, 0)
cell.Value = i + 1
If i + 1 Mod 2 = 0 Then
cell.Style = styleEven
Else
cell.Style = styleOdd
EndIf
Next i

' step 4: save the file


book.Save("c:\temp\hello.xls")
• C#
// step 1: create a new workbook
C1XLBook book = new C1XLBook();

// step 2: create styles for odd and even values


XLStyle styleOdd = new XLStyle(book);
styleOdd.Font = new Font("Tahoma", 9, FontStyle.Italic);
styleOdd.ForeColor = Color.Blue;
XLStyle styleEven = new XLStyle(book);
styleEven.Font = new Font("Tahoma", 9, FontStyle.Bold);
styleEven.ForeColor = Color.Red;

// step 3: write content and styles into some cells


XLSheet sheet = book.Sheets[0];
for (int i = 0; i < 100; i++)
{
XLCell cell = sheet[i, 0];
Creating Documents · 23

cell.Value = i + 1;
cell.Style = ((i+1) % 2 == 0)? styleEven: styleOdd;
}

// step 4: save the file


book.Save(@"c:\temp\hello.xls");
• Delphi
var
book: C1XLBook;
styleOdd: XLStyle;
styleEven: XLStyle;
sheet: XLSheet;
i: Integer;
cell: XLCell;
begin
// step 1: create a new workbook
book := C1XLBook.Create;
styleOdd := XLStyle.Create(book);
styleEven := XLStyle.Create(book);

// step 2: create styles for odd and even values


styleOdd.Font := System.Drawing.Font.Create('Tahoma', 9,
FontStyle.Italic);
styleOdd.ForeColor := Color.Blue;
styleEven.Font := System.Drawing.Font.Create('Tahoma', 9,
FontStyle.Bold);
styleEven.ForeColor := Color.Red;

// step 3: write content and styles into some cells


sheet := book.Sheets[0];
for i := 0 to 99 do
begin
cell := sheet(i, 0);
cell.Value := i + 1;
if (i + 1) mod 2 = 0 then
cell.Style := styleEven
else
cell.Style := styleOdd;
end;

// step 4: save the file


book.Save('c:\temp\hello.xls');
end;
The code is similar. The main difference is the new step 2, which creates styles for odd and even cells. The new
styles are assigned to cells in step 3, along with the cell values.
24 · Using C1XLS

This is what the file created by the code above looks like when opened in Microsoft Excel:

Worksheets
Worksheets are the individual grids contained in an Excel file. They are represented by XLSheet objects
accessible through the Sheets property in the C1XLBook class. Each sheet has a name and contains a
collection of rows and columns. Individual cells can be accessed using the XLSheet indexer, which takes row
and column indices.
The Rows and Columns collections in the XLSheet object extend automatically when you use their indexers.
For example, if you write the following code and the sheet has fewer than 1001 rows, new rows will be
automatically added, and a valid row will be returned. The same applies to XLColumn and XLCell indexers.
This is different from the behavior of most collection indexers in .NET, but it makes it very easy to create and
populate XLSheet objects.
• Visual Basic
Dim sheet As XLSheet = book.Sheets(0)
Dim row As XLRow = sheet.Rows(1000)
• C#
XLSheet sheet = book.Sheets[0];
XLRow row = sheet.Rows[1000];
• Delphi
var
row: XLRow;
sheet: XLSheet;
begin
sheet := book.Sheets[0];
row := sheet.Rows[1000];
end;
Rows and Columns · 25

Rows and Columns


The XLSheet object contains collections of rows and columns that expose each individual row and column on
the sheet. The exposed XLRow and XLColumn objects allow you to assign the size (column width, row
height), visibility, and style for each row and column on the sheet. If you don't assign any of these values, the
sheet's defaults will be used (see the DefaultRowHeight and DefaultColumnWidth properties).
The default dimensions for XLRow and XLColumn objects are –1, which means 'use the sheet's default
values'.

Cells
The XLSheet object also contains cells that can be accessed using an indexer that takes row and column
indices. The cells are represented by XLCell objects that contain the cell value and style.
As with rows and columns, the cell indexer also extends the sheet automatically. For example, write:
• Visual Basic
Dim cell As XLCell = sheet(10, 10)
• C#
XLCell cell = sheet[10,10];
• Delphi
var
cell: XlCell;
begin
cell := sheet[10,10];
end;
If the sheet has fewer than 11 rows and 11 columns, rows and columns will be added and a valid XLCell
object will be returned.
Because the sheet expands automatically, this indexer will never return a null reference. If you want to check
whether a particular cell exists on the sheet and you don't want to create the cell inadvertently, use the sheet's
GetCell method instead of the indexer.
XLCell objects have a Value property that contains the cell contents. This property is of type object and it
may contain strings, numeric, Boolean, DateTime, or null objects. Other types of objects cannot be saved into
Excel files.
XLCell objects also have a Style property that defines the appearance of the cell. If the Style property is set to
null, the cell is displayed using the default style. Otherwise, it should be set to an XLStyle object that defines
the appearance of the cell (font, alignment, colors, format, etc).

Styles
The XLStyle class defines the appearance of a cell, row, or column on a sheet. XLStyle includes properties
that specify style elements such as the font, alignment, colors, and format used to display cell values. Not all
style elements need to be defined in every XLStyle object. For example, if an XLStyle specifies only a format,
then the cell is displayed using the specified format and default settings for the other style elements (font,
alignment, etc.).
C# Samples · 27

C1XLS Samples
Please be advised that this ComponentOne software title is accompanied by various sample projects and/or
demos, which may or not make use of other ComponentOne development tools. While the sample projects
and/or demos included with the software are used to demonstrate and highlight the product’s features, and
how the control may be integrated with the rest of the ComponentOne product line, some of the controls used
in the demo/sample project may not be included with the purchase of certain individual products.
The ComponentOne Samples are also available at
http://helpcentral.componentone.com/ProductResources.aspx.

C# Samples
The sample loops through all cells measuring their contents, then sets the column widths
based on the widest entry. This sample takes into account the cell contents, format and font.
AutoSize
It does not account for content wrapping or merging. This sample calls the C1.C1Excel
namespace.

The sample allows you to create borders around arbitrary ranges. You can control border
width, style, color, etc. When you are done creating the borders, click the last button on the
CellBorder
toolbar to export the grid to Excel, including the custom borders. This sample uses the
C1FlexGrid control and calls the C1.C1Excel namespace.

Demonstrates how to load and save XLS file. This sample uses the C1FlexGrid control and
FlexGrid
calls the C1.C1Excel namespace.

Demonstrates how to create an XLS file and add sheets. This sample calls the C1.C1Excel
HelloWorld
namespace.

C1Excel Frequently Asked Questions


Here are some frequently asked questions about C1Excel:
Does C1Excel support creating or adding formulas or named ranges?
There is no support for creating or adding formulas or named ranges at this time. This feature will be added in
the future. Currently, C1Excel will read and write Excel formulas and named ranges, which allows you to load
existing XLS files, modify some cells, and save the file back to disk preserving the formulas and named ranges.
Adding Content to a Workbook · 29

C1Excel Task-Based Help


Adding Content to a Workbook
This topic demonstrates how to create a new workbook and add values to the first ten cells.
1. Create a new book:
• Visual Basic
Dim book1 As New C1XLBook()
• C#
C1XLBook book1 = new C1XLBook();
• Delphi
var
book1: C1XLBook;
2. Add values to the first ten cells:
• Visual Basic
Dim sheet As XLSheet = book1.Sheets(0)
Dim i As Integer

For i = 0 To 9
sheet(i,0).Value = i + 1
Next i
• C#
XLSheet sheet = book1.Sheets(0);
int i;
for (int i = 0; i <= 9; i++) {
sheet(i,0).Value = i + 1;
}
• Delphi
var
sheet: XLSheet := book1.Sheets(0);
i: integer;

for i := 0 To 9 do
begin
sheet(i,0).Value := i + 1;
end;
3. Save and open the book:
• Visual Basic
book1.Save("c:\mybook.xls")
System.Diagnostics.Process.Start("C:\mybook.xls")
• C#
book1.Save(@"c:\mybook.xls");
System.Diagnostics.Process.Start(@"C:\mybook.xls");
• Delphi
book1.Save("c:\mybook.xls");
System.Diagnostics.Process.Start("C:\mybook.xls");
30 · C1Excel Task-Based Help

Formatting Cells
This topic demonstrates how to format the cells of a book.
1. Create a new book with some content:
• Visual Basic
Dim book1 As New C1XLBook()
Dim sheet As XLSheet = book1.Sheets(0)
Dim i As Integer

For i = 0 To 9
sheet(i,0).Value = i + 1
Next i
• C#
C1XLBook book1 = new C1XLBook();
int i;
for (int i = 0; i <= 9; i++) {
sheet(i,0).Value = i + 1;
}
• Delphi
var
book1: C1XLBook;
sheet: XLSheet := book1.Sheets(0);
Formatting Cells · 31

i: integer;

for i := 0 To 9 do
begin
sheet(i,0).Value := i + 1;
end;
2. Create a new style and assign the style some properties:
• Visual Basic
Dim style1 As New XLStyle(book1)
style1.ForeColor = Color.Gold
style1.BackColor = Color.Blue
style1.Format = "$ .00"
• C#
XLStyle style1 = new XLStyle(book1);
style1.ForeColor = Color.Gold;
style1.BackColor = Color.Blue;
style1.Format = "$ .00";
• Delphi
var
style1: XLStyle(book1);
begin
style1.ForeColor := Color.Gold;
style1.BackColor := Color.Blue;
style1.Format := "$ .00";
end;

3. Save and open the book:


• Visual Basic
book1.Save("c:\mybook.xls")
System.Diagnostics.Process.Start("C:\mybook.xls")
• C#
book1.Save(@"c:\mybook.xls");
System.Diagnostics.Process.Start(@"C:\mybook.xls");
• Delphi
book1.Save("c:\mybook.xls");
System.Diagnostics.Process.Start("C:\mybook.xls");
32 · C1Excel Task-Based Help

Copying Rows from One Book to Another


This topic demonstrates how to copy the rows of a sheet from one book to a second book.
1. Load an existing book:
• Visual Basic
Dim wb As New C1XLBook()
wb.Load("C:\test.xls")
• C#
C1XLBook wb = new C1XLBook();
wb.Load("C:\test.xls");
• Delphi
var
wb: C1XLBook;
begin
wb.Load("C:\text.xls");
end;
2. Create a new XLSheet:
• Visual Basic
Dim xb As New C1XLBook()
xb.Sheets.Add("Test")
Copying Rows from One Book to Another · 33

• C#
C1XLBook xb = new C1XLBook();
xb.Sheets.Add("Test");
• Delphi
var
xb: C1XLBook;
begin
xb.Sheets.Add("Test")
end;
3. Copy each row from the sheet of the existing book to new XLSheet:
• Visual Basic
Dim source As XLSheet = wb.Sheets(0)
Dim dest As XLSheet = xb.Sheets("Test")
Dim row As Integer, col As Integer
For row = 0 To source.Rows.Count - 1
For col = 0 To source.Columns.Count - 1
dest(row, col).Value = source(row, col).Value
Next
Next
• C#
XLSheet source = wb.Sheets[0];
XLSheet dest = xb.Sheets("Test");
int row;
int col;
for (int row = 0; row <= source.Rows.Count - 1; row++) {
for (int col = 0; col <= source.Columns.Count - 1; col++) {
dest(row, col).Value = source(row, col).Value;
}
}
• Delphi
var
source: XLSheet := wb.Sheets[0];
dest: XLSheet := wb.Sheets[0];
row: integer;
col: integer;
for row := 0 to source.Rows.Count - 1 do
begin
for col := 0 to source.Columns.Count – 1 do
dest(row, col).Value := source(row, col).Value;
end;
4. Save and open the new book:
• Visual Basic
xb.Save("C:\test2.xls")
System.Diagnostics.Process.Start("C:\test2.xls")
• C#
xb.Save(@"c:\test2.xls");
System.Diagnostics.Process.Start(@"C:\test2.xls");
• Delphi
xb.Save("c:\test2.xls");
System.Diagnostics.Process.Start("C:\test2.xls");
C1.C1Excel.2 Assembly · 35

C1.C1Excel.2 Assembly
Namespaces
C1.C1Excel

C1.C1Excel Namespace
C1.C1Excel Hierarchy
Classes
Class Description
C1XLBook Represents an Excel workbook containing one or more
worksheets.
Contains methods for loading and saving xls files, and
exposes a collection of XLSheet objects that represent
the individual worksheets.
XLCell Represents individual cells in a XLSheet, and provides
properties for getting and setting the cell Value, Style,
and Hyperlink.
XLCellRange Represents a range of XLCell objects in a XLSheet.
XLCellRangeCollection Represents a collection of XLCellRange objects on an
XLSheet.
XLColumn Represents a column in a worksheet, provides
properties for setting the column's width, style, and
visibility.
XLColumnCollection Represents a collection of XLColumn objects that
represent the individual columns in each XLSheet.
XLPrintSettings Provides options and settings for printing XLSheet
objects.
XLRow Represents a row in a worksheet, provides properties for
setting the row's height, style, and visibility.
XLRowCollection Represents a collection of XLRow objects that
represent the individual rows in each XLSheet.
XLSheet Represents individual worksheets in an Excel workbook
( C1XLBook).
XLSheetCollection Collection of XLSheet objects that represent the
individual worksheets in a C1XLBook.
XLStyle Contains style elements used to define the appearance
of the cells.
36 · C1.C1Excel Namespace

Enumerations
Enumeration Description
XLAlignHorzEnum Specifies how to align cell content horizontally within a
cell.
XLAlignVertEnum Specifies how to align cell content vertically within a
cell.
XLDiagonalFlags Specifies the type of diagonal line to draw across the
cells.
XLLineStyleEnum Specifies the line style used for the cell borders.
XLPatternEnum Specifies the pattern used for To fill the cell
background.
See Also
C1.C1Excel.2 Assembly

C1.C1Excel Hierarchy
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
C1.C1Excel.C1XLBook
C1.C1Excel.XLCell
C1.C1Excel.XLCellRange
C1.C1Excel.XLCellRangeCollection ---- System.Collections.ICollection, System.Collections.IEnumerable
C1.C1Excel.XLColumn
C1.C1Excel.XLColumnCollection ---- System.Collections.ICollection, System.Collections.IEnumerable
C1.C1Excel.XLPrintSettings
C1.C1Excel.XLRow
C1.C1Excel.XLRowCollection ---- System.Collections.ICollection, System.Collections.IEnumerable
C1.C1Excel.XLSheet
C1.C1Excel.XLSheetCollection ---- System.Collections.ICollection, System.Collections.IEnumerable
C1.C1Excel.XLStyle ---- System.ICloneable
System.ValueType
System.[Enum]
C1.C1Excel.XLAlignHorzEnum
C1.C1Excel.XLAlignVertEnum
C1.C1Excel.XLDiagonalFlags
C1.C1Excel.XLLineStyleEnum
C1.C1Excel.XLPatternEnum
C1XLBook Class · 37

See Also
C1.C1Excel Namespace

C1XLBook Class
Represents an Excel workbook containing one or more worksheets.
Contains methods for loading and saving xls files, and exposes a collection of XLSheet objects that represent
the individual worksheets.
For a list of all members of this type, see C1XLBook Members.
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
C1.C1Excel.C1XLBook

[Visual Basic]
Public Class C1XLBook
Inherits Component

[C#]
public class C1XLBook : Component

[Delphi]
type C1XLBook = class (Component);
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
C1XLBook Members | C1.C1Excel Namespace

C1XLBook Members
C1XLBook overview
Public Constructors
C1XLBook Constructor Creates a new instance of the C1XLBook class. The
new workbook contains a single empty XLSheet called
"Sheet1".
Public Properties
DefaultFont Gets or sets the default System.Drawing.Font for the
C1XLBook.
KeepFormulas Gets or sets whether the component should store
formulas read from Xls files and write them back when
saving the file.
Sheets Gets a collection of XLSheet objects that represent the
worksheets in the C1XLBook.
38 · C1.C1Excel Namespace

Public Methods
Clear Clears the C1XLBook, restoring the initial state with a
single XLSheet called "Sheet1".
Load Overloaded. Loads a complete C1XLBook from an xls
file.
PixelsToTwips Converts a pixel measurement into twips (1/20th of a
point).
Save Saves the C1XLBook to an xls file.
TwipsToPixels Converts a twip measurement into screen pixels.
See Also
C1XLBook Class | C1.C1Excel Namespace

C1XLBook Constructor
Creates a new instance of the C1XLBook class. The new workbook contains a single empty XLSheet called
"Sheet1".

[Visual Basic]
Public Function New()

[C#]
public C1XLBook()

[Delphi]
public constructor Create();
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace

C1XLBook Properties
The properties of the C1XLBook class are listed here. For a complete list of C1XLBook class members, see
the C1XLBook Members topic.
Public Properties
DefaultFont Gets or sets the default System.Drawing.Font for the
C1XLBook.
KeepFormulas Gets or sets whether the component should store
formulas read from Xls files and write them back when
saving the file.
Sheets Gets a collection of XLSheet objects that represent the
worksheets in the C1XLBook.

See Also
C1XLBook Class | C1.C1Excel Namespace
C1XLBook.DefaultFont Property · 39

C1XLBook.DefaultFont Property
Gets or sets the default System.Drawing.Font for the C1XLBook.

[Visual Basic]
Public Property DefaultFont As Font

[C#]
public Font DefaultFont {get;set;}

[Delphi]
public property DefaultFont: Font read get_DefaultFont write
set_DefaultFont;
Remarks
You can assign any font to any cell using XLStyle objects. Cells that have no associated custom styles or have
styles that do not define a custom font are displayed using the book's default font.
The DefaultFont property is initially set to 10 pt Arial.
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace

C1XLBook.KeepFormulas Property
Gets or sets whether the component should store formulas read from Xls files and write them back when
saving the file.

[Visual Basic]
Public Property KeepFormulas As Boolean

[C#]
public bool KeepFormulas {get;set;}

[Delphi]
public property KeepFormulas: Boolean read get_KeepFormulas write
set_KeepFormulas;
Remarks
Setting this property to true allows you to load existing XLS files, modify the values in some cells, and save the
file preserving the formulas. This is the default setting.
Setting this property to false causes the component to remove the formulas in the book when it is loaded.
Saving the file in this case will retain the last calculated values but will remove the formulas.
The component does not provide any support for creating or editing formulas. Formulas must be created in
Excel.
Assigning any value to a cell will clear the formula in the cell.
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace
40 · C1.C1Excel Namespace

C1XLBook.Sheets Property
Gets a collection of XLSheet objects that represent the worksheets in the C1XLBook.

[Visual Basic]
Public ReadOnly Property Sheets As XLSheetCollection

[C#]
public XLSheetCollection Sheets {get;}

[Delphi]
public property Sheets: XLSheetCollection read get_Sheets;
Remarks
The XLSheetCollection returned has methods for counting, enumerating, adding and removing sheets from
the C1XLBook.
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace

C1XLBook Methods
The methods of the C1XLBook class are listed here. For a complete list of C1XLBook class members, see the
C1XLBook Members topic.
Public Methods
Clear Clears the C1XLBook, restoring the initial state with a
single XLSheet called "Sheet1".
Load Overloaded. Loads a complete C1XLBook from an xls
file.
PixelsToTwips Converts a pixel measurement into twips (1/20th of a
point).
Save Saves the C1XLBook to an xls file.
TwipsToPixels Converts a twip measurement into screen pixels.
See Also
C1XLBook Class | C1.C1Excel Namespace

C1XLBook.Clear Method
Clears the C1XLBook, restoring the initial state with a single XLSheet called "Sheet1".

[Visual Basic]
Public Sub Clear()

[C#]
public void Clear()

[Delphi]
public procedure Clear();
C1XLBook.Load Method · 41

Remarks
The Clear method restores the C1XLBook object to its initial state, with a single empty sheet called "Sheet1"
and the DefaultFont set to 10pt Arial.
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace

C1XLBook.Load Method
Overload List
Loads a complete C1XLBook from an xls file.
[Visual Basic] Overloads Public Sub Load(String)
[C#] public void Load(string);
[Delphi] public procedure Load(String); overload;
Loads a list of the worksheets in an xls file, optionally skipping the data contained in the sheets.
[Visual Basic] Overloads Public Sub Load(String, Boolean)
[C#] public void Load(string, bool);
[Delphi] public procedure Load(String; Boolean); overload;
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace

C1XLBook.Load Method (String)


Loads a complete C1XLBook from an xls file.

[Visual Basic]
Overloads Public Sub Load( _
ByVal fileName As String _
)

[C#]
public void Load(
string fileName
);

[Delphi]
public procedure Load(
fileName: String
); overload;
Parameters
fileName
Name of the xls file to load.
Remarks
If the file doesn't exist, is locked, or is not a valid Excel file, an exception will be thrown..
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace | C1XLBook.Load Overload List
42 · C1.C1Excel Namespace

C1XLBook.Load Method (String, Boolean)


Loads a list of the worksheets in an xls file, optionally skipping the data contained in the sheets.

[Visual Basic]
Overloads Public Sub Load( _
ByVal fileName As String, _
ByVal fillSheets As Boolean _
)

[C#]
public void Load(
string fileName,
bool fillSheets
);

[Delphi]
public procedure Load(
fileName: String;
fillSheets: Boolean
); overload;
Parameters
fileName
Name of the xls file to load.
fillSheets
True to read the sheet data, false to read only the sheet names.
Remarks
Loading the worksheets without their data is much faster than loading the entire workbook. This is useful in
situations where you want to examine the contents of the xls file (for example, to ensure that you will not
overwrite an existing sheet).
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace | C1XLBook.Load Overload List

C1XLBook.PixelsToTwips Method
Converts a pixel measurement into twips (1/20th of a point).

[Visual Basic]
Public Shared Function PixelsToTwips( _
ByVal pix As Double _
) As Integer

[C#]
public static int PixelsToTwips(
double pix
);

[Delphi]
public class function PixelsToTwips(
pix: Double
): Int32;
C1XLBook.Save Method · 43

Parameters
pix
Measurement in screen pixels.
Return Value
Measurement in twips.
Remarks
Excel stores measurements in twips (1/20th of a point), a resolution-independent unit. .NET controls, on the
other hand, usually express measurements in pixels. This method provides an easy way to convert pixel
measurements into twips using the current screen resolution.
TwipsToPixels
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace

C1XLBook.Save Method
Saves the C1XLBook to an xls file.

[Visual Basic]
Public Sub Save( _
ByVal fileName As String _
)

[C#]
public void Save(
string fileName
);

[Delphi]
public procedure Save(
fileName: String
);
Parameters
fileName
Name of the xls file to save.
Remarks
If the file can't be created, an exception will be thrown. This typically indicates that the file is currently open by
another application (such as Microsoft Excel).
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace

C1XLBook.TwipsToPixels Method
Converts a twip measurement into screen pixels.
[Visual Basic]
Public Shared Function TwipsToPixels( _
ByVal twip As Double _
) As Integer
44 · C1.C1Excel Namespace

[C#]
public static int TwipsToPixels(
double twip
);

[Delphi]
public class function TwipsToPixels(
twip: Double
): Int32;
Parameters
twip
Measurement in twips.
Return Value
Measurement in screen pixels.
Remarks
Excel stores measurements in twips (1/20th of a point), a resolution-independent unit. .NET controls, on the
other hand, usually express measurements in pixels. This method provides an easy way to convert pixel
measurements into twips using the current screen resolution.
PixelsToTwips
See Also
C1XLBook Class | C1XLBook Members | C1.C1Excel Namespace

XLAlignHorzEnum Enumeration
Specifies how to align cell content horizontally within a cell.

[Visual Basic]
Public Enum XLAlignHorzEnum

[C#]
public enum XLAlignHorzEnum

[Delphi]
type XLAlignHorzEnum = (Center, Fill, General, Justify, Left, Right,
Selection, Undefined);
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
Members
Member name Description
Center Align to cell center.
Fill Fill cell, repeating content as necessary.
General Align strings to the left, numbers to the right.
Justify Justify content horizontally to span the whole cell
width.
XLAlignVertEnum Enumeration · 45

Member name Description


Left Align to cell left.
Right Align to cell right.
Selection Align to selection center (may span multiple cells).
Undefined Not specified (use default).
See Also
C1.C1Excel Namespace

XLAlignVertEnum Enumeration
Specifies how to align cell content vertically within a cell.

[Visual Basic]
Public Enum XLAlignVertEnum

[C#]
public enum XLAlignVertEnum

[Delphi]
type XLAlignVertEnum = (Bottom, Center, Justify, Top, Undefined);
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
Members
Member name Description
Bottom Align to cell bottom.
Center Align to cell center.
Justify Justify content vertically to span the whole cell height.
Top Align to cell top.
Undefined Not specified (use default).
See Also
C1.C1Excel Namespace

XLCell Class
Represents individual cells in a XLSheet, and provides properties for getting and setting the cell Value, Style,
and Hyperlink.
For a list of all members of this type, see XLCell Members.
System.Object
C1.C1Excel.XLCell

[Visual Basic]
Public Class XLCell
46 · C1.C1Excel Namespace

[C#]
public class XLCell

[Delphi]
type XLCell = class;
Remarks
To create cells, use the XLSheet indexer (Item property). If the cell already exists, the reference will be
returned as usual. If not, the sheet will create the cell (as well as rows and columns if necessary) and will return
a reference to the new cell.
Because it creates cells automatically, the indexer is especially useful when creating and populating sheets.
Example
For example, the code below creates a new C1XLBook, then populates the first sheet with a 10 by 10
multiplication table:
• Visual Basic
Dim book As New C1XLBook()
Dim sheet As XLSheet = book.Sheets(0)
Dim r As Integer
For r = 0 To 9
Dim c As Integer
For c = 0 To 9
Dim cell As XLCell = sheet(r, c)
cell.Value =(r + 1) *(c + 1)
Next c
Next r
book.Save("c:\temp\test.xls")
• C#
C1XLBook book = new C1XLBook();
XLSheet sheet = book.Sheets[0];
for (int r = 0; r < 10; r++)
{
for (int c = 0; c < 10; c++)
{
XLCell cell = sheet[r, c];
cell.Value = (r+1) * (c+1);
}
}
book.Save(@"c:\temp\test.xls");
• Delphi
var
book: C1XLBook;
sheet: XLSheet;
r: Integer;
c: Integer;
cell: XLCell;
begin
book := C1XLBook.Create;
sheet := book.Sheets[0];
for r := 0 to 9 do
begin
for c := 0 to 9 do
begin
cell := sheet[r, c];
XLCell.Hyperlink Property · 47

cell.Value := (r + 1) * (c + 1);
end;
end;
book.Save('c:\temp\test.xls');
end;
Note how the code simply accesses the cells using the indexer. There's no need to create any rows, columns,
or cells. The indexer takes care of all that automatically.
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLCell Members | C1.C1Excel Namespace

XLCell Members
XLCell overview
Public Properties
Hyperlink Gets or sets a string that specifies an action to take
when the cell is clicked.
Style Gets or sets the XLStyle object associated with the cell.
Value Gets or sets the value stored in the cell .
See Also
XLCell Class | C1.C1Excel Namespace

XLCell Properties
The properties of the XLCell class are listed here. For a complete list of XLCell class members, see the
XLCell Members topic.
Public Properties
Hyperlink Gets or sets a string that specifies an action to take
when the cell is clicked.
Style Gets or sets the XLStyle object associated with the cell.
Value Gets or sets the value stored in the cell .
See Also
XLCell Class | C1.C1Excel Namespace

XLCell.Hyperlink Property
Gets or sets a string that specifies an action to take when the cell is clicked.

[Visual Basic]
Public Property Hyperlink As String

[C#]
public string Hyperlink {get;set;}
48 · C1.C1Excel Namespace

[Delphi]
public property Hyperlink: String read get_Hyperlink write set_Hyperlink;
Remarks
Hyperlinks may contain URLs that when clicked open a browser window and navigate to the specified site
(e.g. "http://www.componentone.com"). They may also contain references to files that are launched by the
application associated with the file type (e.g. "readme.doc"). Finally, hyperlinks can be used to send e-mails
(e.g. "mailto:joe@foo.com").
Each cell may contain a hyperlink and a value. However, if you assign a hyperlink to a cell that has no value
(Value == null), then the hyperlink text is automatically assigned to the cell value as well.
See Also
XLCell Class | XLCell Members | C1.C1Excel Namespace

XLCell.Style Property
Gets or sets the XLStyle object associated with the cell.

[Visual Basic]
Public Property Style As XLStyle

[C#]
public XLStyle Style {get;set;}

[Delphi]
public property Style: XLStyle read get_Style write set_Style;
Remarks
The appearance of each cell is defined by one or more XLStyle objects.
When displaying a cell, Excel combines the row, column, and cell styles and merges the style elements defined
in each one in order to determine how the cell should be displayed.
The precedence of the styles is: (1) cell, (2) row, (3) column, (4) default style. For example, if a cell style
defines the font and background color, those will be applied regardless of the settings in the row and column
styles. If the row style defines an alignment, that will be applied regardless of the column style, and so on.
The cell style may be null, in which case the cell is displayed using the other styles available or the default
book style if no others are available.
See Also
XLCell Class | XLCell Members | C1.C1Excel Namespace

XLCell.Value Property
Gets or sets the value stored in the cell .

[Visual Basic]
Public Property Value As Object

[C#]
public object Value {get;set;}

[Delphi]
public property Value: Object read get_Value write set_Value;
XLCellRange Class · 49

Remarks
The value may contain strings, numeric, boolean, System.DateTime, or null objects. Other types of object
can't be saved into Excel files.
DateTime values are internally converted into doubles, and stored in the sheet as such. The only way to tell
the difference between a DateTime value and a double in Excel is by way of the format associated with the cell
(Format property).
See Also
XLCell Class | XLCell Members | C1.C1Excel Namespace

XLCellRange Class
Represents a range of XLCell objects in a XLSheet.
For a list of all members of this type, see XLCellRange Members.
System.Object
C1.C1Excel.XLCellRange

[Visual Basic]
Public Class XLCellRange

[C#]
public class XLCellRange

[Delphi]
type XLCellRange = class;
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLCellRange Members | C1.C1Excel Namespace

XLCellRange Members
XLCellRange overview
Public Constructors
XLCellRange Constructor Creates an instance of a XLCellRange object
containing an empty range.
Public Properties
ColumnCount Gets the number of columns in the range.
ColumnFrom Gets index of the left column in the range.
ColumnTo Gets or sets the index of the last column in the range.
IsEmpty Determines whether the range is empty.
RowCount Gets the number of rows in the range.
RowFrom Gets the index of the top row in the range.
RowTo Gets or sets the index of the last row in the range.
50 · C1.C1Excel Namespace

Public Methods
Contains Determines whether the range contains a specific cell.
Intersects Determines whether the range intersects another range.
See Also
XLCellRange Class | C1.C1Excel Namespace

XLCellRange Constructor
Overload List
Creates an instance of a XLCellRange object containing an empty range.
[Visual Basic] Public Function New()
[C#] public XLCellRange();
[Delphi] public constructor Create(); overload;
Creates an instance of a XLCellRange object containing a specified range.
[Visual Basic] Public Function New(Integer, Integer, Integer, Integer)
[C#] public XLCellRange(int, int, int, int);
[Delphi] public constructor Create(Int32; Int32; Int32; Int32); overload;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRange Constructor ()
Creates an instance of a XLCellRange object containing an empty range.

[Visual Basic]
Public Function New()

[C#]
public XLCellRange()

[Delphi]
public constructor Create(); overload;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace | XLCellRange Constructor
Overload List

XLCellRange Constructor (Int32, Int32, Int32, Int32)


Creates an instance of a XLCellRange object containing a specified range.

[Visual Basic]
Public Function New( _
ByVal rowFrom As Integer, _
ByVal rowTo As Integer, _
ByVal colFrom As Integer, _
ByVal colTo As Integer _
)
XLCellRange Class · 51

[C#]
public XLCellRange(
int rowFrom,
int rowTo,
int colFrom,
int colTo
);

[Delphi]
public constructor Create(
rowFrom: Int32;
rowTo: Int32;
colFrom: Int32;
colTo: Int32
); overload;
Parameters
rowFrom
Top row in the range.
rowTo
Bottom row in the range.
colFrom
Left column in the range.
colTo
Bottom column in the range.
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace | XLCellRange Constructor
Overload List

XLCellRange Properties
The properties of the XLCellRange class are listed here. For a complete list of XLCellRange class members,
see the XLCellRange Members topic.
Public Properties
ColumnCount Gets the number of columns in the range.
ColumnFrom Gets index of the left column in the range.
ColumnTo Gets or sets the index of the last column in the range.
IsEmpty Determines whether the range is empty.
RowCount Gets the number of rows in the range.
RowFrom Gets the index of the top row in the range.
RowTo Gets or sets the index of the last row in the range.
See Also
XLCellRange Class | C1.C1Excel Namespace
52 · C1.C1Excel Namespace

XLCellRange.ColumnCount Property
Gets the number of columns in the range.

[Visual Basic]
Public ReadOnly Property ColumnCount As Integer

[C#]
public int ColumnCount {get;}

[Delphi]
public property ColumnCount: Int32 read get_ColumnCount;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRange.ColumnFrom Property
Gets index of the left column in the range.

[Visual Basic]
Public ReadOnly Property ColumnFrom As Integer

[C#]
public int ColumnFrom {get;}

[Delphi]
public property ColumnFrom: Int32 read get_ColumnFrom;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRange.ColumnTo Property
Gets or sets the index of the last column in the range.

[Visual Basic]
Public Property ColumnTo As Integer

[C#]
public int ColumnTo {get;set;}

[Delphi]
public property ColumnTo: Int32 read get_ColumnTo write set_ColumnTo;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRange.IsEmpty Property
Determines whether the range is empty.

[Visual Basic]
Public ReadOnly Property IsEmpty As Boolean
XLCellRange.RowCount Property · 53

[C#]
public bool IsEmpty {get;}

[Delphi]
public property IsEmpty: Boolean read get_IsEmpty;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRange.RowCount Property
Gets the number of rows in the range.

[Visual Basic]
Public ReadOnly Property RowCount As Integer

[C#]
public int RowCount {get;}

[Delphi]
public property RowCount: Int32 read get_RowCount;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRange.RowFrom Property
Gets the index of the top row in the range.

[Visual Basic]
Public ReadOnly Property RowFrom As Integer

[C#]
public int RowFrom {get;}

[Delphi]
public property RowFrom: Int32 read get_RowFrom;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRange.RowTo Property
Gets or sets the index of the last row in the range.

[Visual Basic]
Public Property RowTo As Integer

[C#]
public int RowTo {get;set;}

[Delphi]
public property RowTo: Int32 read get_RowTo write set_RowTo;
54 · C1.C1Excel Namespace

See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRange Methods
The methods of the XLCellRange class are listed here. For a complete list of XLCellRange class members,
see the XLCellRange Members topic.
Public Methods
Contains Determines whether the range contains a specific cell.
Intersects Determines whether the range intersects another range.
See Also
XLCellRange Class | C1.C1Excel Namespace

XLCellRange.Contains Method
Determines whether the range contains a specific cell.

[Visual Basic]
Public Function Contains( _
ByVal row As Integer, _
ByVal col As Integer _
) As Boolean

[C#]
public bool Contains(
int row,
int col
);

[Delphi]
public function Contains(
row: Int32;
col: Int32
): Boolean;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRange.Intersects Method
Determines whether the range intersects another range.

[Visual Basic]
Public Function Intersects( _
ByVal cr As XLCellRange _
) As Boolean

[C#]
public bool Intersects(
XLCellRange cr
);
XLCellRangeCollection Class · 55

[Delphi]
public function Intersects(
cr: XLCellRange
): Boolean;
See Also
XLCellRange Class | XLCellRange Members | C1.C1Excel Namespace

XLCellRangeCollection Class
Represents a collection of XLCellRange objects on an XLSheet.
For a list of all members of this type, see XLCellRangeCollection Members.
System.Object
C1.C1Excel.XLCellRangeCollection

[Visual Basic]
Public Class XLCellRangeCollection
Implements ICollection, IEnumerable

[C#]
public class XLCellRangeCollection : ICollection, IEnumerable

[Delphi]
type XLCellRangeCollection = class (TObject, ICollection, IEnumerable);
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection Members
XLCellRangeCollection overview
Public Properties
Count Gets the number of XLCellRange objects in the collection.
Item Gets the XLCellRange object at the specified position in the collection.
Sheet Gets the XLSheet object that owns the collection.
Public Methods
Add Overloaded. Appends an XLCellRange object to the collection.
Clear Removes all XLCellRange objects from the collection.
Contains Checks whether the collection contains a specific XLCellRange object.
IndexOf Gets the position of an XLCellRange object in the collection.
Insert Inserts an XLCellRange object at a specific position in the collection.
56 · C1.C1Excel Namespace

Remove Removes an XLCellRange object from the collection.


RemoveAt Removes an XLCellRange object at a specific position from the
collection.
See Also
XLCellRangeCollection Class | C1.C1Excel Namespace

XLCellRangeCollection Properties
The properties of the XLCellRangeCollection class are listed here. For a complete list of
XLCellRangeCollection class members, see the XLCellRangeCollection Members topic.
Public Properties
Count Gets the number of XLCellRange objects in the collection.
Item Gets the XLCellRange object at the specified position in the collection.
Sheet Gets the XLSheet object that owns the collection.
See Also
XLCellRangeCollection Class | C1.C1Excel Namespace

XLCellRangeCollection.Count Property
Gets the number of XLCellRange objects in the collection.

[Visual Basic]
Public ReadOnly Property Count As Integer

[C#]
public int Count {get;}

[Delphi]
public property Count: Int32 read get_Count;
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection.Item Property
Gets the XLCellRange object at the specified position in the collection.

[Visual Basic]
Public Default ReadOnly Property Item( _
ByVal index As Integer _
) As XLCellRange

[C#]
public XLCellRange this[
int index
] {get;}
XLCellRangeCollection.Sheet Property · 57

[Delphi]
public property Item[
index: Int32
]: XLCellRange read get_Item;
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection.Sheet Property
Gets the XLSheet object that owns the collection.

[Visual Basic]
Public ReadOnly Property Sheet As XLSheet

[C#]
public XLSheet Sheet {get;}

[Delphi]
public property Sheet: XLSheet read get_Sheet;
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection Methods
The methods of the XLCellRangeCollection class are listed here. For a complete list of
XLCellRangeCollection class members, see the XLCellRangeCollection Members topic.
Public Methods
Add Overloaded. Appends an XLCellRange object to the
collection.
Clear Removes all XLCellRange objects from the collection.
Contains Checks whether the collection contains a specific
XLCellRange object.
IndexOf Gets the position of an XLCellRange object in the
collection.
Insert Inserts an XLCellRange object at a specific position in
the collection.
Remove Removes an XLCellRange object from the collection.
RemoveAt Removes an XLCellRange object at a specific position
from the collection.
See Also
XLCellRangeCollection Class | C1.C1Excel Namespace

XLCellRangeCollection.Add Method
Overload List
Creates an XLCellRange object and appends it to the collection.
[Visual Basic] Overloads Public Function Add(Integer, Integer, Integer, Integer) As XLCellRange
58 · C1.C1Excel Namespace

[C#] public XLCellRange Add(int, int, int, int);


[Delphi] public function Add(Int32; Int32; Int32; Int32) : XLCellRange; overload;
Appends an XLCellRange object to the collection.
[Visual Basic] Overloads Public Function Add(XLCellRange) As XLCellRange
[C#] public XLCellRange Add(XLCellRange);
[Delphi] public function Add(XLCellRange) : XLCellRange; overload;
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection.Add Method (Int32, Int32, Int32, Int32)


Creates an XLCellRange object and appends it to the collection.

[Visual Basic]
Overloads Public Function Add( _
ByVal rowIndex As Integer, _
ByVal colIndex As Integer, _
ByVal rowCount As Integer, _
ByVal colCount As Integer _
) As XLCellRange

[C#]
public XLCellRange Add(
int rowIndex,
int colIndex,
int rowCount,
int colCount
);

[Delphi]
public function Add(
rowIndex: Int32;
colIndex: Int32;
rowCount: Int32;
colCount: Int32
): XLCellRange; overload;
Parameters
rowIndex
Index of the top row in the cell range.
colIndex
Index of the left column in the cell range.
rowCount
Number of rows in the cell range.
colCount
Number of columns in the cell range.
XLCellRangeCollection.Clear Method · 59

Return Value
A reference to the object if it was successfully added to the collection, or null if the object could not be added
to the collection (usually because it overlaps another cell range already in the collection).
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace |
XLCellRangeCollection.Add Overload List

XLCellRangeCollection.Add Method (XLCellRange)


Appends an XLCellRange object to the collection.

[Visual Basic]
Overloads Public Function Add( _
ByVal cr As XLCellRange _
) As XLCellRange

[C#]
public XLCellRange Add(
XLCellRange cr
);

[Delphi]
public function Add(
cr: XLCellRange
): XLCellRange; overload;
Parameters
cr
XLCellRange object to add to the collection.
Return Value
A reference to the object if it was successfully added to the collection, or null if the object could not be added
to the collection (usually because it overlaps another cell range already in the collection).
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace |
XLCellRangeCollection.Add Overload List

XLCellRangeCollection.Clear Method
Removes all XLCellRange objects from the collection.

[Visual Basic]
Public Sub Clear()

[C#]
public void Clear()

[Delphi]
public procedure Clear();
60 · C1.C1Excel Namespace

See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection.Contains Method
Checks whether the collection contains a specific XLCellRange object.

[Visual Basic]
Public Function Contains( _
ByVal cr As XLCellRange _
) As Boolean

[C#]
public bool Contains(
XLCellRange cr
);

[Delphi]
public function Contains(
cr: XLCellRange
): Boolean;
Parameters
cr
XLCellRange object to look for.
Return Value
True if the collection contains the range, False otherwise.
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection.IndexOf Method
Gets the position of an XLCellRange object in the collection.

[Visual Basic]
Public Function IndexOf( _
ByVal cr As XLCellRange _
) As Integer

[C#]
public int IndexOf(
XLCellRange cr
);

[Delphi]
public function IndexOf(
cr: XLCellRange
): Int32;
XLCellRangeCollection.Insert Method · 61

Parameters
cr
XLCellRange object to look for.
Return Value
The position of the object in the collection, or -1 if the object is not a member of the collection
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection.Insert Method
Inserts an XLCellRange object at a specific position in the collection.

[Visual Basic]
Public Function Insert( _
ByVal index As Integer, _
ByVal cr As XLCellRange _
) As XLCellRange

[C#]
public XLCellRange Insert(
int index,
XLCellRange cr
);

[Delphi]
public function Insert(
index: Int32;
cr: XLCellRange
): XLCellRange;
Parameters
index
Position where the object will be inserted.
cr
Object to insert in the collection.
Return Value
A reference to the object if it was successfully added to the collection, or null if the object could not be added
to the collection (usually because it overlaps another cell range already in the collection).
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection.Remove Method
Removes an XLCellRange object from the collection.

[Visual Basic]
Public Sub Remove( _
ByVal cr As XLCellRange _
)
62 · C1.C1Excel Namespace

[C#]
public void Remove(
XLCellRange cr
);

[Delphi]
public procedure Remove(
cr: XLCellRange
);
Parameters
cr
XLCellRange object to remove from the collection.
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLCellRangeCollection.RemoveAt Method
Removes an XLCellRange object at a specific position from the collection.

[Visual Basic]
Public Sub RemoveAt( _
ByVal index As Integer _
)

[C#]
public void RemoveAt(
int index
);

[Delphi]
public procedure RemoveAt(
index: Int32
);
Parameters
index
Index of the object to remove from the collection.
See Also
XLCellRangeCollection Class | XLCellRangeCollection Members | C1.C1Excel Namespace

XLColumn Class
Represents a column in a worksheet, provides properties for setting the column's width, style, and visibility.
For a list of all members of this type, see XLColumn Members.
System.Object
C1.C1Excel.XLColumn
XLColumn Members · 63

[Visual Basic]
Public Class XLColumn

[C#]
public class XLColumn

[Delphi]
type XLColumn = class;
Remarks
The XLColumn objects do not contain any data. If you remove a column from the collection, the data will be
lost. If you later re-insert that same column back into the collection, the column will be blank.
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLColumn Members | C1.C1Excel Namespace

XLColumn Members
XLColumn overview
Public Constructors
XLColumn Constructor Creates a new instance of the XLColumn class.
Public Properties
Book Gets a reference to the parent C1XLBook object.
Sheet Gets a reference to the parent XLSheet object.
Style Gets or sets the XLStyle object that determines the
appearance of the column.
Visible Gets or sets whether the column is visible.
Width Gets or sets the width of the column, in twips.
See Also
XLColumn Class | C1.C1Excel Namespace

XLColumn Constructor
Creates a new instance of the XLColumn class.

[Visual Basic]
Public Function New()

[C#]
public XLColumn()

[Delphi]
public constructor Create();
64 · C1.C1Excel Namespace

See Also
XLColumn Class | XLColumn Members | C1.C1Excel Namespace

XLColumn Properties
The properties of the XLColumn class are listed here. For a complete list of XLColumn class members, see
the XLColumn Members topic.
Public Properties
Book Gets a reference to the parent C1XLBook object.
Sheet Gets a reference to the parent XLSheet object.
Style Gets or sets the XLStyle object that determines the
appearance of the column.
Visible Gets or sets whether the column is visible.
Width Gets or sets the width of the column, in twips.
See Also
XLColumn Class | C1.C1Excel Namespace

XLColumn.Book Property
Gets a reference to the parent C1XLBook object.

[Visual Basic]
Public ReadOnly Property Book As C1XLBook

[C#]
public C1XLBook Book {get;}

[Delphi]
public property Book: C1XLBook read get_Book;
See Also
XLColumn Class | XLColumn Members | C1.C1Excel Namespace

XLColumn.Sheet Property
Gets a reference to the parent XLSheet object.

[Visual Basic]
Public ReadOnly Property Sheet As XLSheet

[C#]
public XLSheet Sheet {get;}

[Delphi]
public property Sheet: XLSheet read get_Sheet;
See Also
XLColumn Class | XLColumn Members | C1.C1Excel Namespace
XLColumn.Style Property · 65

XLColumn.Style Property
Gets or sets the XLStyle object that determines the appearance of the column.

[Visual Basic]
Public Property Style As XLStyle

[C#]
public XLStyle Style {get;set;}

[Delphi]
public property Style: XLStyle read get_Style write set_Style;
See Also
XLColumn Class | XLColumn Members | C1.C1Excel Namespace

XLColumn.Visible Property
Gets or sets whether the column is visible.

[Visual Basic]
Public Property Visible As Boolean

[C#]
public bool Visible {get;set;}

[Delphi]
public property Visible: Boolean read get_Visible write set_Visible;
See Also
XLColumn Class | XLColumn Members | C1.C1Excel Namespace

XLColumn.Width Property
Gets or sets the width of the column, in twips.

[Visual Basic]
Public Property Width As Integer

[C#]
public int Width {get;set;}

[Delphi]
public property Width: Int32 read get_Width write set_Width;
Remarks
A value of -1 indicates that the column should be displayed using the sheet's DefaultColumnWidth.
To convert between pixels and twips, use the TwipsToPixels and PixelsToTwips methods.
See Also
XLColumn Class | XLColumn Members | C1.C1Excel Namespace
66 · C1.C1Excel Namespace

XLColumnCollection Class
Represents a collection of XLColumn objects that represent the individual columns in each XLSheet.
For a list of all members of this type, see XLColumnCollection Members.
System.Object
C1.C1Excel.XLColumnCollection

[Visual Basic]
Public Class XLColumnCollection
Implements ICollection, IEnumerable

[C#]
public class XLColumnCollection : ICollection, IEnumerable

[Delphi]
type XLColumnCollection = class (TObject, ICollection, IEnumerable);
Remarks
The collection has methods for counting, enumerating, adding, and removing columns from the collection.
The XLColumn objects do not contain any data. If you remove a column from the collection, the data will be
lost. If you later re-insert that same column back into the collection, the column will be blank.
Example
Note that you can create columns automatically by using the sheet's indexer. For example, the following code
retrieves the cell at coordinates (3,3) and in doing so automatically creates four rows and four columns
automatically:
• Visual Basic
Dim book As New C1XLBook()
Dim sheet As XLSheet = book.Sheets(0)
Dim cell As XLCell = sheet(3, 3) ' creates 4 rows and 4 columns
• C#
C1XLBook book = new C1XLBook();
XLSheet sheet = book.Sheets[0];
XLCell cell = sheet[3,3]; // creates 4 rows and 4 columns
• Delphi
var
book: C1XLBook;
sheet: XLSheet;
cell: XLCell;
begin
book := C1XLBook.Create;
sheet := book.Sheets[0];
cell := sheet[3,3]; //creates 4 rows and 4 columns
end;
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLColumnCollection Members | C1.C1Excel Namespace
XLColumnCollection Members · 67

XLColumnCollection Members
XLColumnCollection overview
Public Properties
Book Gets a reference to the parent C1XLBook object.
Count Gets the number of items in the collection.
Frozen Gets or sets the number of frozen columns in the
collection.
Item Returns a reference to the XLColumn object at the
specified index.
Sheet Gets a reference to the parent XLSheet object.
Public Methods
Add Overloaded. Creates a new XLColumn object and adds
it to the collection.
Clear Removes all items from the collection.
Contains Determines whether an XLColumn is a member of the
collection.
IndexOf Gets the index of a given XLRow object in the
collection.
Insert Overloaded. Creates a new XLColumn object and
inserts it at a specific position in the collection.
Remove Removes an XLColumn object from the collection.
RemoveAt Removes the XLColumn object at a given position
from the collection.
See Also
XLColumnCollection Class | C1.C1Excel Namespace

XLColumnCollection Properties
The properties of the XLColumnCollection class are listed here. For a complete list of XLColumnCollection
class members, see the XLColumnCollection Members topic.
Public Properties
Book Gets a reference to the parent C1XLBook object.
Count Gets the number of items in the collection.
Frozen Gets or sets the number of frozen columns in the
collection.
Item Returns a reference to the XLColumn object at the
specified index.
Sheet Gets a reference to the parent XLSheet object.
See Also
XLColumnCollection Class | C1.C1Excel Namespace
68 · C1.C1Excel Namespace

XLColumnCollection.Book Property
Gets a reference to the parent C1XLBook object.

[Visual Basic]
Public ReadOnly Property Book As C1XLBook

[C#]
public C1XLBook Book {get;}

[Delphi]
public property Book: C1XLBook read get_Book;
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection.Count Property
Gets the number of items in the collection.

[Visual Basic]
Public ReadOnly Property Count As Integer

[C#]
public int Count {get;}

[Delphi]
public property Count: Int32 read get_Count;
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection.Frozen Property
Gets or sets the number of frozen columns in the collection.

[Visual Basic]
Public Property Frozen As Integer

[C#]
public int Frozen {get;set;}

[Delphi]
public property Frozen: Int32 read get_Frozen write set_Frozen;
Remarks
Frozen columns are displayed on the right side of the sheet and do not scroll horizontally. They are useful for
displaying row headers.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection.Item Property
Returns a reference to the XLColumn object at the specified index.
XLColumnCollection.Sheet Property · 69

[Visual Basic]
Public Default ReadOnly Property Item( _
ByVal index As Integer _
) As XLColumn

[C#]
public XLColumn this[
int index
] {get;}

[Delphi]
public property Item[
index: Int32
]: XLColumn read get_Item;
Remarks
The indexer will create a new XLColumn object at the specified position if necessary. It never returns null.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection.Sheet Property
Gets a reference to the parent XLSheet object.

[Visual Basic]
Public ReadOnly Property Sheet As XLSheet

[C#]
public XLSheet Sheet {get;}

[Delphi]
public property Sheet: XLSheet read get_Sheet;
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection Methods
The methods of the XLColumnCollection class are listed here. For a complete list of XLColumnCollection
class members, see the XLColumnCollection Members topic.
Public Methods
Add Overloaded. Creates a new XLColumn object and adds
it to the collection.
Clear Removes all items from the collection.
Contains Determines whether an XLColumn is a member of the
collection.
IndexOf Gets the index of a given XLRow object in the
collection.
Insert Overloaded. Creates a new XLColumn object and
inserts it at a specific position in the collection.
70 · C1.C1Excel Namespace

Remove Removes an XLColumn object from the collection.


RemoveAt Removes the XLColumn object at a given position
from the collection.
See Also
XLColumnCollection Class | C1.C1Excel Namespace

XLColumnCollection.Add Method
Overload List
Creates a new XLColumn object and adds it to the collection.
[Visual Basic] Overloads Public Function Add() As XLColumn
[C#] public XLColumn Add();
[Delphi] public function Add() : XLColumn; overload;
Adds an XLColumn object to the collection.
[Visual Basic] Overloads Public Function Add(XLColumn) As XLColumn
[C#] public XLColumn Add(XLColumn);
[Delphi] public function Add(XLColumn) : XLColumn; overload;
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection.Add Method ()
Creates a new XLColumn object and adds it to the collection.

[Visual Basic]
Overloads Public Function Add() As XLColumn

[C#]
public XLColumn Add()

[Delphi]
public function Add(): XLColumn; overload;
Return Value
A reference to the new XLColumn object.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace |
XLColumnCollection.Add Overload List

XLColumnCollection.Add Method (XLColumn)


Adds an XLColumn object to the collection.

[Visual Basic]
Overloads Public Function Add( _
ByVal col As XLColumn _
) As XLColumn
XLColumnCollection.Clear Method · 71

[C#]
public XLColumn Add(
XLColumn col
);

[Delphi]
public function Add(
col: XLColumn
): XLColumn; overload;
Parameters
col
The item to add to the collection.
Return Value
A reference to the item that was added to the collection (in this case, always the col parameter.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace |
XLColumnCollection.Add Overload List

XLColumnCollection.Clear Method
Removes all items from the collection.

[Visual Basic]
Public Sub Clear()

[C#]
public void Clear()

[Delphi]
public procedure Clear();
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection.Contains Method
Determines whether an XLColumn is a member of the collection.

[Visual Basic]
Public Function Contains( _
ByVal col As XLColumn _
) As Boolean

[C#]
public bool Contains(
XLColumn col
);
72 · C1.C1Excel Namespace

[Delphi]
public function Contains(
col: XLColumn
): Boolean;
Parameters
col
Item to look for.
Return Value
True if the collection contains the item, False otherwise.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection.IndexOf Method
Gets the index of a given XLRow object in the collection.

[Visual Basic]
Public Function IndexOf( _
ByVal col As XLColumn _
) As Integer

[C#]
public int IndexOf(
XLColumn col
);

[Delphi]
public function IndexOf(
col: XLColumn
): Int32;
Parameters
col
Item to look for.
Return Value
The position of the item in the collection, or -1 if the item is not a member of the collection.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection.Insert Method
Overload List
Creates a new XLColumn object and inserts it at a specific position in the collection.
[Visual Basic] Overloads Public Function Insert(Integer) As XLColumn
[C#] public XLColumn Insert(int);
[Delphi] public function Insert(Int32) : XLColumn; overload;
XLColumnCollection.Insert Method · 73

Inserts an XLColumn object at a specific position in the collection.


[Visual Basic] Overloads Public Function Insert(Integer, XLColumn) As XLColumn
[C#] public XLColumn Insert(int, XLColumn);
[Delphi] public function Insert(Int32; XLColumn) : XLColumn; overload;
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLColumnCollection.Insert Method (Int32)


Creates a new XLColumn object and inserts it at a specific position in the collection.

[Visual Basic]
Overloads Public Function Insert( _
ByVal index As Integer _
) As XLColumn

[C#]
public XLColumn Insert(
int index
);

[Delphi]
public function Insert(
index: Int32
): XLColumn; overload;
Parameters
index
Position where the new item will be inserted.
Return Value
A reference to the new item.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace |
XLColumnCollection.Insert Overload List

XLColumnCollection.Insert Method (Int32, XLColumn)


Inserts an XLColumn object at a specific position in the collection.

[Visual Basic]
Overloads Public Function Insert( _
ByVal index As Integer, _
ByVal col As XLColumn _
) As XLColumn

[C#]
public XLColumn Insert(
int index,
XLColumn col
);
74 · C1.C1Excel Namespace

[Delphi]
public function Insert(
index: Int32;
col: XLColumn
): XLColumn; overload;
Parameters
index
Position where the item will be inserted.
col
Item that will be inserted.
Return Value
A reference to the item that was added to the collection.
Remarks
The maximum number of XLColumn objects in a XLSheet is 256. This is a limitation imposed by Excel.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace |
XLColumnCollection.Insert Overload List

XLColumnCollection.Remove Method
Removes an XLColumn object from the collection.

[Visual Basic]
Public Function Remove( _
ByVal col As XLColumn _
) As XLColumn

[C#]
public XLColumn Remove(
XLColumn col
);

[Delphi]
public function Remove(
col: XLColumn
): XLColumn;
Parameters
col
Item to be removed from the collection.
Return Value
A reference to the item that was removed.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace
XLColumnCollection.RemoveAt Method · 75

XLColumnCollection.RemoveAt Method
Removes the XLColumn object at a given position from the collection.

[Visual Basic]
Public Function RemoveAt( _
ByVal index As Integer _
) As XLColumn

[C#]
public XLColumn RemoveAt(
int index
);

[Delphi]
public function RemoveAt(
index: Int32
): XLColumn;
Parameters
index
Index of the item to remove from the collection.
Return Value
A reference to the item that was removed from the collection.
See Also
XLColumnCollection Class | XLColumnCollection Members | C1.C1Excel Namespace

XLDiagonalFlags Enumeration
Specifies the type of diagonal line to draw across the cells.

[Visual Basic]
Public Enum XLDiagonalFlags

[C#]
public enum XLDiagonalFlags

[Delphi]
type XLDiagonalFlags = (Backward, Forward, None);
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
Members
Member name Description
Backward Backward diagonal (\).
Forward Forward diagonal (/).
None No diagonal.
76 · C1.C1Excel Namespace

See Also
C1.C1Excel Namespace

XLLineStyleEnum Enumeration
Specifies the line style used for the cell borders.

[Visual Basic]
Public Enum XLLineStyleEnum

[C#]
public enum XLLineStyleEnum

[Delphi]
type XLLineStyleEnum = (Dashed, Dotted, Double, Hair, Medium,
MediumDashDotDotted, MediumDashDotted, MediumDashed, None,
SlantedMediumDashDotted, Thick, Thin, ThinDashDotDotted, ThinDashDotted);
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
Members
Member name Description
Dashed Dashed.
Dotted Dotted.
Double Double.
Hair Hair (one pixel).
Medium Medium.
MediumDashDotDotted Medium dash-dot-dot.
MediumDashDotted Medium dash-dot.
MediumDashed Medium dashed.
None No line.
SlantedMediumDashDotted Slanted dash-dot.
Thick Thick.
Thin Thin.
ThinDashDotDotted Thin dash-dot-dot.
ThinDashDotted Thin dash-dot.
See Also
C1.C1Excel Namespace

XLPatternEnum Enumeration
Specifies the pattern used for To fill the cell background.
XLPatternEnum Enumeration · 77

[Visual Basic]
Public Enum XLPatternEnum

[C#]
public enum XLPatternEnum

[Delphi]
type XLPatternEnum = (DiagonalCrosshatch, DiagonalStripe, Gray06, Gray12,
Gray25, Gray50, Gray75, HorizontalStripe, None, ReverseDiagonalStripe,
Solid, ThickDiagonalCrosshatch, ThinDiagonalCrosshatch,
ThinDiagonalStripe, ThinHorizontalCrosshatch, ThinHorizontalStripe,
ThinReverseDiagonalStripe, ThinVerticalStripe, VerticalStripe);
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
Members
Member name Description
DiagonalCrosshatch Diagonal crosshatch pattern.
DiagonalStripe Diagonal stripe pattern (/).
Gray06 6% dotted pattern.
Gray12 12% dotted pattern.
Gray25 25% dotted pattern.
Gray50 50% dotted pattern.
Gray75 75% dotted pattern.
HorizontalStripe Horizontal stripe pattern.
None No pattern (transparent).
ReverseDiagonalStripe Reverse diagonal stripe pattern (\).
Solid Solid background.
ThickDiagonalCrosshatch Thick diagonal crosshatch pattern.
ThinDiagonalCrosshatch Thin diagonal crosshatch pattern.
ThinDiagonalStripe Thin diagonal stripe pattern (/).
ThinHorizontalCrosshatch Thin horizontal crosshatch pattern.
ThinHorizontalStripe Thin horizontal stripe pattern.
ThinReverseDiagonalStripe Thin reverse diagonal stripe pattern (\).
ThinVerticalStripe Thin vertical stripe pattern.
VerticalStripe Vertical stripe pattern.
See Also
C1.C1Excel Namespace
78 · C1.C1Excel Namespace

XLPrintSettings Class
Provides options and settings for printing XLSheet objects.
For a list of all members of this type, see XLPrintSettings Members.
System.Object
C1.C1Excel.XLPrintSettings

[Visual Basic]
Public Class XLPrintSettings

[C#]
public class XLPrintSettings

[Delphi]
type XLPrintSettings = class;
Remarks
The settings are applied to each sheet, and are accessible through the sheet's PrintSettings property.
Note that C1XLBook does not provide any printing services. The settings are used when printing the sheet
from Excel.
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings Members
XLPrintSettings overview
Public Constructors
XLPrintSettings Constructor Creates a new instance of the XLPrintSettings class.
Public Properties
AutoScale Gets or sets the scaling mode used for printed output.
BlackAndWhite Gets or sets whether to print the sheet in monochrome
mode.
CenterHorizontal Gets or sets whether the sheet should be centered
horizontally on the page when printed.
CenterVertical Gets or sets whether the sheet should be centered
vertically on the page when printed.
Copies Gets or sets the number of copies to print.
DraftQuality Gets or sets whether to print the sheet in draft quality
mode.
FitPagesAcross Fit the sheet to this number of pages across (0 means
use as many as needed).
XLPrintSettings Constructor · 79

FitPagesDown Fit the sheet to this number of pages down (0 means use
as many as needed).
Footer Gets or sets the string to be displayed as a page header
when the sheet is printed.
Header Gets or sets the string to be displayed as a page header
when the sheet is printed.
Landscape Gets or sets whether to print the sheet in landscape
mode.
MarginBottom Gets or sets the bottom margin, in inches. Set to a
negative value to use the default margin.
MarginFooter Gets or sets the footer margin, in inches. Set to a
negative value to use the default margin.
MarginHeader Gets or sets the header margin, in inches. Set to a
negative value to use the default margin.
MarginLeft Gets or sets the left margin, in inches. Set to a negative
value to use the default margin.
MarginRight Gets or sets the right margin, in inches. Set to a negative
value to use the default margin.
MarginTop Gets or sets the top margin, in inches. Set to a negative
value to use the default margin.
PaperKind Gets or sets the paper size to use when printing the
sheet.
PrintGridlines Gets or sets whether the gridlines will be printed.
PrintHeaders Gets or sets whether row and column headers (the areas
with row numbers and column letters) will be printed.
PrintPagesInRows Gets or sets whether to print the pages in rows (across
first) or in columns (down first).
ScalingFactor Gets or sets the scaling factor (in percent) to use when
printing the sheet.
StartPage Gets or sets the initial page number to use when
printing the sheet.
See Also
XLPrintSettings Class | C1.C1Excel Namespace

XLPrintSettings Constructor
Creates a new instance of the XLPrintSettings class.

[Visual Basic]
Public Function New()

[C#]
public XLPrintSettings()
80 · C1.C1Excel Namespace

[Delphi]
public constructor Create();
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings Properties
The properties of the XLPrintSettings class are listed here. For a complete list of XLPrintSettings class
members, see the XLPrintSettings Members topic.
Public Properties
AutoScale Gets or sets the scaling mode used for printed output.
BlackAndWhite Gets or sets whether to print the sheet in monochrome
mode.
CenterHorizontal Gets or sets whether the sheet should be centered
horizontally on the page when printed.
CenterVertical Gets or sets whether the sheet should be centered
vertically on the page when printed.
Copies Gets or sets the number of copies to print.
DraftQuality Gets or sets whether to print the sheet in draft quality
mode.
FitPagesAcross Fit the sheet to this number of pages across (0 means
use as many as needed).
FitPagesDown Fit the sheet to this number of pages down (0 means use
as many as needed).
Footer Gets or sets the string to be displayed as a page header
when the sheet is printed.
Header Gets or sets the string to be displayed as a page header
when the sheet is printed.
Landscape Gets or sets whether to print the sheet in landscape
mode.
MarginBottom Gets or sets the bottom margin, in inches. Set to a
negative value to use the default margin.
MarginFooter Gets or sets the footer margin, in inches. Set to a
negative value to use the default margin.
MarginHeader Gets or sets the header margin, in inches. Set to a
negative value to use the default margin.
MarginLeft Gets or sets the left margin, in inches. Set to a negative
value to use the default margin.
MarginRight Gets or sets the right margin, in inches. Set to a negative
value to use the default margin.
MarginTop Gets or sets the top margin, in inches. Set to a negative
value to use the default margin.
PaperKind Gets or sets the paper size to use when printing the
sheet.
XLPrintSettings.AutoScale Property · 81

PrintGridlines Gets or sets whether the gridlines will be printed.


PrintHeaders Gets or sets whether row and column headers (the areas
with row numbers and column letters) will be printed.
PrintPagesInRows Gets or sets whether to print the pages in rows (across
first) or in columns (down first).
ScalingFactor Gets or sets the scaling factor (in percent) to use when
printing the sheet.
StartPage Gets or sets the initial page number to use when
printing the sheet.
See Also
XLPrintSettings Class | C1.C1Excel Namespace

XLPrintSettings.AutoScale Property
Gets or sets the scaling mode used for printed output.

[Visual Basic]
Public Property AutoScale As Boolean

[C#]
public bool AutoScale {get;set;}

[Delphi]
public property AutoScale: Boolean read get_AutoScale write set_AutoScale;
Remarks
If AutoScale is set to true, then the printed sheet will be automatically scaled to fit the number of pages
specified by the FitPagesAcross and FitPagesDown properties.
If AutoScale is set to false, then the printed sheet will be scaled according to the value of the ScalingFactor
property.
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.BlackAndWhite Property
Gets or sets whether to print the sheet in monochrome mode.

[Visual Basic]
Public Property BlackAndWhite As Boolean

[C#]
public bool BlackAndWhite {get;set;}

[Delphi]
public property BlackAndWhite: Boolean read get_BlackAndWhite write
set_BlackAndWhite;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace
82 · C1.C1Excel Namespace

XLPrintSettings.CenterHorizontal Property
Gets or sets whether the sheet should be centered horizontally on the page when printed.

[Visual Basic]
Public Property CenterHorizontal As Boolean

[C#]
public bool CenterHorizontal {get;set;}

[Delphi]
public property CenterHorizontal: Boolean read get_CenterHorizontal write
set_CenterHorizontal;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.CenterVertical Property
Gets or sets whether the sheet should be centered vertically on the page when printed.

[Visual Basic]
Public Property CenterVertical As Boolean

[C#]
public bool CenterVertical {get;set;}

[Delphi]
public property CenterVertical: Boolean read get_CenterVertical write
set_CenterVertical;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.Copies Property
Gets or sets the number of copies to print.

[Visual Basic]
Public Property Copies As Integer

[C#]
public int Copies {get;set;}

[Delphi]
public property Copies: Int32 read get_Copies write set_Copies;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.DraftQuality Property
Gets or sets whether to print the sheet in draft quality mode.
XLPrintSettings.FitPagesAcross Property · 83

[Visual Basic]
Public Property DraftQuality As Boolean

[C#]
public bool DraftQuality {get;set;}

[Delphi]
public property DraftQuality: Boolean read get_DraftQuality write
set_DraftQuality;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.FitPagesAcross Property
Fit the sheet to this number of pages across (0 means use as many as needed).

[Visual Basic]
Public Property FitPagesAcross As Integer

[C#]
public int FitPagesAcross {get;set;}

[Delphi]
public property FitPagesAcross: Int32 read get_FitPagesAcross write
set_FitPagesAcross;
Remarks
causes C1Excel to select fit to page print mode, ignoring the value of the ScalingFactor property. Setting the
FitPagesAcross or FitPagesDown properties automatically sets the AutoScale property to true, causing
C1Excel to calculate the scaling factor based on the given number of pages and to ignore the value of the
ScalingFactor property.
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.FitPagesDown Property
Fit the sheet to this number of pages down (0 means use as many as needed).

[Visual Basic]
Public Property FitPagesDown As Integer

[C#]
public int FitPagesDown {get;set;}

[Delphi]
public property FitPagesDown: Int32 read get_FitPagesDown write
set_FitPagesDown;
Remarks
Setting the FitPagesAcross or FitPagesDown properties automatically sets the AutoScale property to true,
causing C1Excel to calculate the scaling factor based on the given number of pages and to ignore the value of
the ScalingFactor property.
84 · C1.C1Excel Namespace

See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.Footer Property
Gets or sets the string to be displayed as a page header when the sheet is printed.

[Visual Basic]
Public Property Footer As String

[C#]
public string Footer {get;set;}

[Delphi]
public property Footer: String read get_Footer write set_Footer;
Remarks
The footer string has the same structure and embedded commands as the header string. See the Header
property for details.
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.Header Property
Gets or sets the string to be displayed as a page header when the sheet is printed.

[Visual Basic]
Public Property Header As String

[C#]
public string Header {get;set;}

[Delphi]
public property Header: String read get_Header write set_Header;
Remarks
The header string may contain special commands, i.e. placeholders for the page number, current date, or text
formatting attributes. Most of these fields are represented by single letters with a leading ampersand ("&").
The page header is divided into 3 sections: left, center, and right. Each section is introduced by a special
command ("&L", "&C", and "&R"). All text and all commands following are part of the selected section.
The following commands are available:
&L Start of the left section
&C Start of the centred section
&R Start of the right section
&P Current page number
&N Page count
&D Current date
&T Current time
XLPrintSettings.Landscape Property · 85

&A Sheet name


&F File name without path
&Z File path without file name
&G Picture (file name)
&B Bold toggle
&I Italic toggle
&U Underline toggle
&E Double underle toggle
&S Strikeout toggle
&X Superscript toggle
&Y Subscript toggle
&"[fontname]" Set new font
&"[fontname,fontstyle]" Set new font with specified style. The style is in most cases "Regular", "Bold", "Italic",
or "Bold Italic". &[fontheight] Set font height in points.
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.Landscape Property
Gets or sets whether to print the sheet in landscape mode.

[Visual Basic]
Public Property Landscape As Boolean

[C#]
public bool Landscape {get;set;}

[Delphi]
public property Landscape: Boolean read get_Landscape write set_Landscape;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.MarginBottom Property
Gets or sets the bottom margin, in inches. Set to a negative value to use the default margin.

[Visual Basic]
Public Property MarginBottom As Double

[C#]
public double MarginBottom {get;set;}

[Delphi]
public property MarginBottom: Double read get_MarginBottom write
set_MarginBottom;
86 · C1.C1Excel Namespace

See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.MarginFooter Property
Gets or sets the footer margin, in inches. Set to a negative value to use the default margin.

[Visual Basic]
Public Property MarginFooter As Double

[C#]
public double MarginFooter {get;set;}

[Delphi]
public property MarginFooter: Double read get_MarginFooter write
set_MarginFooter;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.MarginHeader Property
Gets or sets the header margin, in inches. Set to a negative value to use the default margin.

[Visual Basic]
Public Property MarginHeader As Double

[C#]
public double MarginHeader {get;set;}

[Delphi]
public property MarginHeader: Double read get_MarginHeader write
set_MarginHeader;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.MarginLeft Property
Gets or sets the left margin, in inches. Set to a negative value to use the default margin.

[Visual Basic]
Public Property MarginLeft As Double

[C#]
public double MarginLeft {get;set;}

[Delphi]
public property MarginLeft: Double read get_MarginLeft write
set_MarginLeft;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace
XLPrintSettings.MarginRight Property · 87

XLPrintSettings.MarginRight Property
Gets or sets the right margin, in inches. Set to a negative value to use the default margin.

[Visual Basic]
Public Property MarginRight As Double

[C#]
public double MarginRight {get;set;}

[Delphi]
public property MarginRight: Double read get_MarginRight write
set_MarginRight;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.MarginTop Property
Gets or sets the top margin, in inches. Set to a negative value to use the default margin.

[Visual Basic]
Public Property MarginTop As Double

[C#]
public double MarginTop {get;set;}

[Delphi]
public property MarginTop: Double read get_MarginTop write set_MarginTop;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.PaperKind Property
Gets or sets the paper size to use when printing the sheet.

[Visual Basic]
Public Property PaperKind As PaperKind

[C#]
public PaperKind PaperKind {get;set;}

[Delphi]
public property PaperKind: PaperKind read get_PaperKind write
set_PaperKind;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.PrintGridlines Property
Gets or sets whether the gridlines will be printed.
88 · C1.C1Excel Namespace

[Visual Basic]
Public Property PrintGridlines As Boolean

[C#]
public bool PrintGridlines {get;set;}

[Delphi]
public property PrintGridlines: Boolean read get_PrintGridlines write
set_PrintGridlines;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.PrintHeaders Property
Gets or sets whether row and column headers (the areas with row numbers and column letters) will be printed.

[Visual Basic]
Public Property PrintHeaders As Boolean

[C#]
public bool PrintHeaders {get;set;}

[Delphi]
public property PrintHeaders: Boolean read get_PrintHeaders write
set_PrintHeaders;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.PrintPagesInRows Property
Gets or sets whether to print the pages in rows (across first) or in columns (down first).

[Visual Basic]
Public Property PrintPagesInRows As Boolean

[C#]
public bool PrintPagesInRows {get;set;}

[Delphi]
public property PrintPagesInRows: Boolean read get_PrintPagesInRows write
set_PrintPagesInRows;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.ScalingFactor Property
Gets or sets the scaling factor (in percent) to use when printing the sheet.

[Visual Basic]
Public Property ScalingFactor As Integer
XLPrintSettings.StartPage Property · 89

[C#]
public int ScalingFactor {get;set;}

[Delphi]
public property ScalingFactor: Int32 read get_ScalingFactor write
set_ScalingFactor;
Remarks
Setting the ScalingFactor property automatically sets the AutoScale property to false, causing C1Excel to use
the selected scaling factor and to ignore the value of the FitPagesAcross and FitPagesDown properties.
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLPrintSettings.StartPage Property
Gets or sets the initial page number to use when printing the sheet.

[Visual Basic]
Public Property StartPage As Integer

[C#]
public int StartPage {get;set;}

[Delphi]
public property StartPage: Int32 read get_StartPage write set_StartPage;
See Also
XLPrintSettings Class | XLPrintSettings Members | C1.C1Excel Namespace

XLRow Class
Represents a row in a worksheet, provides properties for setting the row's height, style, and visibility.
For a list of all members of this type, see XLRow Members.
System.Object
C1.C1Excel.XLRow

[Visual Basic]
Public Class XLRow

[C#]
public class XLRow

[Delphi]
type XLRow = class;
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLRow Members | C1.C1Excel Namespace
90 · C1.C1Excel Namespace

XLRow Members
XLRow overview
Public Constructors
XLRow Constructor Creates a new instance of the XLRow class.
Public Properties
Book Gets a reference to the parent C1XLBook object.
Height Gets or sets the height of the row, in twips.
Sheet Gets a reference to the parent XLSheet object.
Style Gets or sets the XLStyle object that determines the
appearance of the row.
Visible Gets or sets whether the row is visible.
See Also
XLRow Class | C1.C1Excel Namespace

XLRow Constructor
Creates a new instance of the XLRow class.

[Visual Basic]
Public Function New()

[C#]
public XLRow()

[Delphi]
public constructor Create();
See Also
XLRow Class | XLRow Members | C1.C1Excel Namespace

XLRow Properties
The properties of the XLRow class are listed here. For a complete list of XLRow class members, see the
XLRow Members topic.
Public Properties
Book Gets a reference to the parent C1XLBook object.
Height Gets or sets the height of the row, in twips.
Sheet Gets a reference to the parent XLSheet object.
Style Gets or sets the XLStyle object that determines the
appearance of the row.
Visible Gets or sets whether the row is visible.
XLRow.Book Property · 91

See Also
XLRow Class | C1.C1Excel Namespace

XLRow.Book Property
Gets a reference to the parent C1XLBook object.

[Visual Basic]
Public ReadOnly Property Book As C1XLBook

[C#]
public C1XLBook Book {get;}

[Delphi]
public property Book: C1XLBook read get_Book;
See Also
XLRow Class | XLRow Members | C1.C1Excel Namespace

XLRow.Height Property
Gets or sets the height of the row, in twips.

[Visual Basic]
Public Property Height As Integer

[C#]
public int Height {get;set;}

[Delphi]
public property Height: Int32 read get_Height write set_Height;
Remarks
A value of -1 indicates that the row should be displayed using the sheet's DefaultRowHeight.
To convert between pixels and twips, use the TwipsToPixels and PixelsToTwips methods.
See Also
XLRow Class | XLRow Members | C1.C1Excel Namespace

XLRow.Sheet Property
Gets a reference to the parent XLSheet object.

[Visual Basic]
Public ReadOnly Property Sheet As XLSheet

[C#]
public XLSheet Sheet {get;}

[Delphi]
public property Sheet: XLSheet read get_Sheet;
92 · C1.C1Excel Namespace

See Also
XLRow Class | XLRow Members | C1.C1Excel Namespace

XLRow.Style Property
Gets or sets the XLStyle object that determines the appearance of the row.

[Visual Basic]
Public Property Style As XLStyle

[C#]
public XLStyle Style {get;set;}

[Delphi]
public property Style: XLStyle read get_Style write set_Style;
See Also
XLRow Class | XLRow Members | C1.C1Excel Namespace

XLRow.Visible Property
Gets or sets whether the row is visible.

[Visual Basic]
Public Property Visible As Boolean

[C#]
public bool Visible {get;set;}

[Delphi]
public property Visible: Boolean read get_Visible write set_Visible;
See Also
XLRow Class | XLRow Members | C1.C1Excel Namespace

XLRowCollection Class
Represents a collection of XLRow objects that represent the individual rows in each XLSheet.
For a list of all members of this type, see XLRowCollection Members.
System.Object
C1.C1Excel.XLRowCollection

[Visual Basic]
Public Class XLRowCollection
Implements ICollection, IEnumerable

[C#]
public class XLRowCollection : ICollection, IEnumerable

[Delphi]
type XLRowCollection = class (TObject, ICollection, IEnumerable);
XLRowCollection Members · 93

Remarks
The collection has methods for counting, enumerating, adding, and removing rows from the collection.
Example
Note that you can create rows automatically by using the sheet's indexer. For example, the following code
retrieves the cell at coordinates (3,3) and in doing so automatically creates four rows and four columns
automatically:
• Visual Basic
Dim book As New C1XLBook()
Dim sheet As XLSheet = book.Sheets(0)
Dim cell As XLCell = sheet(3, 3) ' creates 4 rows and 4 columns
• C#
C1XLBook book = new C1XLBook();
sheet = book.Sheets[0];
XLCell cell = sheet[3,3]; // creates 4 rows and 4 columns
• Delphi
var
book: C1XLBook;
sheet: XLSheet;
cell: XLCell;
begin
book := C1XLBook.Create;
sheet := book.Sheets[0];
//creates 4 rows and 4 columns;
cell := sheet[3, 3];
end;
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection Members
XLRowCollection overview
Public Properties
Book Gets a reference to the parent C1XLBook object.
Count Gets the number of items in the collection.
Frozen Gets or sets the number of frozen rows in the collection.
Item Returns a reference to the XLRow object at the
specified index.
Sheet Gets a reference to the parent XLSheet object.
Public Methods
Add Overloaded. Creates a new XLRow object and adds it
to the collection.
Clear Removes all items from the collection.
94 · C1.C1Excel Namespace

Contains Determines whether an XLRow is a member of the


collection.
IndexOf Gets the index of a given XLRow object in the
collection.
Insert Overloaded. Creates a new XLRow object and inserts it
at a specific position in the collection.
Remove Removes an XLRow object from the collection.
RemoveAt Removes the XLRow object at a given position from
the collection.
See Also
XLRowCollection Class | C1.C1Excel Namespace

XLRowCollection Properties
The properties of the XLRowCollection class are listed here. For a complete list of XLRowCollection class
members, see the XLRowCollection Members topic.
Public Properties
Book Gets a reference to the parent C1XLBook object.
Count Gets the number of items in the collection.
Frozen Gets or sets the number of frozen rows in the collection.
Item Returns a reference to the XLRow object at the
specified index.
Sheet Gets a reference to the parent XLSheet object.
See Also
XLRowCollection Class | C1.C1Excel Namespace

XLRowCollection.Book Property
Gets a reference to the parent C1XLBook object.

[Visual Basic]
Public ReadOnly Property Book As C1XLBook

[C#]
public C1XLBook Book {get;}

[Delphi]
public property Book: C1XLBook read get_Book;
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.Count Property
Gets the number of items in the collection.
XLRowCollection.Frozen Property · 95

[Visual Basic]
Public ReadOnly Property Count As Integer

[C#]
public int Count {get;}

[Delphi]
public property Count: Int32 read get_Count;
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.Frozen Property
Gets or sets the number of frozen rows in the collection.

[Visual Basic]
Public Property Frozen As Integer

[C#]
public int Frozen {get;set;}

[Delphi]
public property Frozen: Int32 read get_Frozen write set_Frozen;
Remarks
Frozen rows are displayed on the top of the sheet and do not scroll vertically. They are useful for displaying
column headers.
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.Item Property
Returns a reference to the XLRow object at the specified index.

[Visual Basic]
Public Default ReadOnly Property Item( _
ByVal index As Integer _
) As XLRow

[C#]
public XLRow this[
int index
] {get;}

[Delphi]
public property Item[
index: Int32
]: XLRow read get_Item;
Remarks
The indexer will create a new XLRow object at the specified position if necessary. It never returns null.
96 · C1.C1Excel Namespace

See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.Sheet Property
Gets a reference to the parent XLSheet object.

[Visual Basic]
Public ReadOnly Property Sheet As XLSheet

[C#]
public XLSheet Sheet {get;}

[Delphi]
public property Sheet: XLSheet read get_Sheet;
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection Methods
The methods of the XLRowCollection class are listed here. For a complete list of XLRowCollection class
members, see the XLRowCollection Members topic.
Public Methods
Add Overloaded. Creates a new XLRow object and adds it
to the collection.
Clear Removes all items from the collection.
Contains Determines whether an XLRow is a member of the
collection.
IndexOf Gets the index of a given XLRow object in the
collection.
Insert Overloaded. Creates a new XLRow object and inserts it
at a specific position in the collection.
Remove Removes an XLRow object from the collection.
RemoveAt Removes the XLRow object at a given position from
the collection.
See Also
XLRowCollection Class | C1.C1Excel Namespace

XLRowCollection.Add Method
Overload List
Creates a new XLRow object and adds it to the collection.
[Visual Basic] Overloads Public Function Add() As XLRow
[C#] public XLRow Add();
[Delphi] public function Add() : XLRow; overload;
XLRowCollection.Add Method · 97

Adds an XLRow object to the collection.


[Visual Basic] Overloads Public Function Add(XLRow) As XLRow
[C#] public XLRow Add(XLRow);
[Delphi] public function Add(XLRow) : XLRow; overload;
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.Add Method ()
Creates a new XLRow object and adds it to the collection.

[Visual Basic]
Overloads Public Function Add() As XLRow

[C#]
public XLRow Add()

[Delphi]
public function Add(): XLRow; overload;
Return Value
A reference to the new XLRow object.
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace | XLRowCollection.Add
Overload List

XLRowCollection.Add Method (XLRow)


Adds an XLRow object to the collection.

[Visual Basic]
Overloads Public Function Add( _
ByVal row As XLRow _
) As XLRow

[C#]
public XLRow Add(
XLRow row
);

[Delphi]
public function Add(
row: XLRow
): XLRow; overload;
Parameters
row
The item to add to the collection.
Return Value
A reference to the item that was added to the collection (in this case, always the row parameter.
98 · C1.C1Excel Namespace

See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace | XLRowCollection.Add
Overload List

XLRowCollection.Clear Method
Removes all items from the collection.

[Visual Basic]
Public Sub Clear()

[C#]
public void Clear()

[Delphi]
public procedure Clear();
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.Contains Method
Determines whether an XLRow is a member of the collection.

[Visual Basic]
Public Function Contains( _
ByVal row As XLRow _
) As Boolean

[C#]
public bool Contains(
XLRow row
);

[Delphi]
public function Contains(
row: XLRow
): Boolean;
Parameters
row
Item to look for.
Return Value
True if the collection contains the item, False otherwise.
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.IndexOf Method
Gets the index of a given XLRow object in the collection.
XLRowCollection.Insert Method · 99

[Visual Basic]
Public Function IndexOf( _
ByVal row As XLRow _
) As Integer

[C#]
public int IndexOf(
XLRow row
);

[Delphi]
public function IndexOf(
row: XLRow
): Int32;
Parameters
row
Item to look for.
Return Value
The position of the item in the collection, or -1 if the item is not a member of the collection.
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.Insert Method
Overload List
Creates a new XLRow object and inserts it at a specific position in the collection.
[Visual Basic] Overloads Public Function Insert(Integer) As XLRow
[C#] public XLRow Insert(int);
[Delphi] public function Insert(Int32) : XLRow; overload;
Inserts an XLRow object at a specific position in the collection.
[Visual Basic] Overloads Public Function Insert(Integer, XLRow) As XLRow
[C#] public XLRow Insert(int, XLRow);
[Delphi] public function Insert(Int32; XLRow) : XLRow; overload;
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.Insert Method (Int32)


Creates a new XLRow object and inserts it at a specific position in the collection.

[Visual Basic]
Overloads Public Function Insert( _
ByVal index As Integer _
) As XLRow
100 · C1.C1Excel Namespace

[C#]
public XLRow Insert(
int index
);

[Delphi]
public function Insert(
index: Int32
): XLRow; overload;
Parameters
index
Position where the new item will be inserted.
Return Value
A reference to the new item.
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace | XLRowCollection.Insert
Overload List

XLRowCollection.Insert Method (Int32, XLRow)


Inserts an XLRow object at a specific position in the collection.

[Visual Basic]
Overloads Public Function Insert( _
ByVal index As Integer, _
ByVal row As XLRow _
) As XLRow

[C#]
public XLRow Insert(
int index,
XLRow row
);

[Delphi]
public function Insert(
index: Int32;
row: XLRow
): XLRow; overload;
Parameters
index
Position where the item will be inserted.
row
Item that will be inserted.
Return Value
A reference to the item that was added to the collection.
XLRowCollection.Remove Method · 101

Remarks
The maximum number of XLRow objects in a XLSheet is 65,536. This is a limitation imposed by Excel.
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace | XLRowCollection.Insert
Overload List

XLRowCollection.Remove Method
Removes an XLRow object from the collection.

[Visual Basic]
Public Function Remove( _
ByVal row As XLRow _
) As XLRow

[C#]
public XLRow Remove(
XLRow row
);

[Delphi]
public function Remove(
row: XLRow
): XLRow;
Parameters
row
Item to be removed from the collection.
Return Value
A reference to the item that was removed.
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLRowCollection.RemoveAt Method
Removes the XLRow object at a given position from the collection.

[Visual Basic]
Public Function RemoveAt( _
ByVal index As Integer _
) As XLRow

[C#]
public XLRow RemoveAt(
int index
);

[Delphi]
public function RemoveAt(
index: Int32
): XLRow;
102 · C1.C1Excel Namespace

Parameters
index
Index of the item to remove from the collection.
Return Value
A reference to the item that was removed from the collection.
See Also
XLRowCollection Class | XLRowCollection Members | C1.C1Excel Namespace

XLSheet Class
Represents individual worksheets in an Excel workbook ( C1XLBook).
For a list of all members of this type, see XLSheet Members.
System.Object
C1.C1Excel.XLSheet

[Visual Basic]
Public Class XLSheet

[C#]
public class XLSheet

[Delphi]
type XLSheet = class;
Remarks
Provides indexers to get or set the value of individual cells ( XLCell) and to access the Rows and Columns on
the sheet.
Example
Use the C1XLBook Sheets indexer to get an individual sheet. For example, the code below gets a reference to
the first sheet on the book, then prints the number of rows and columns on the sheet:
• Visual Basic
Dim book As New C1XLBook()
Dim sheet As XLSheet = book.Sheets(0)
Console.WriteLine("Sheet has {0} rows and {1} columns", _
sheet.Rows.Count, sheet.Columns.Count)
• C#
C1XLBook book = new C1XLBook();
XLSheet sheet = book.Sheets[0];
Console.WriteLine("Sheet has {0} rows and {1} columns",
sheet.Rows.Count, sheet.Columns.Count);
• Delphi
var
sheet: XLSheet;
book: C1XLBook;
begin
book := C1XLBook.Create;
sheet := book.Sheets[0];
XLSheet Members · 103

Console.WriteLine('Sheet has {0} rows and {1} columns',


sheet.Rows.Count, sheet.Columns.Count);
end;
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLSheet Members | C1.C1Excel Namespace

XLSheet Members
XLSheet overview
Public Properties
Book Gets a reference to the C1XLBook that owns the sheet.
Columns Gets a reference to sheet's column collection.
DefaultColumnWidth Gets or sets the default row height for the sheet (in
twips).
DefaultRowHeight Gets or sets the default row height for the sheet (in
twips).
Locked Gets or sets a value that determines if the sheet is locked
for editing.
MergedCells Gets a XLCellRangeCollection that contains the
collection of cells that are merged on the sheet.
Name Gets or sets the name of the XLSheet.
PrintSettings Gets or sets an XLPrintSettings object that controls
how the sheet is printed.
Rows Gets a reference to sheet's row collection.
ShowGridLines Gets or sets whether Excel should show the grid lines
when displaying the sheet.
Visible Gets or sets the sheet's visibility.
Public Methods
Clone Creates a copy of this sheet.
GetCell Gets a reference to a cell at the specified coordinates, or
null of the cell doesn't exist.
See Also
XLSheet Class | C1.C1Excel Namespace

XLSheet Properties
The properties of the XLSheet class are listed here. For a complete list of XLSheet class members, see the
XLSheet Members topic.
Public Properties
Book Gets a reference to the C1XLBook that owns the sheet.
104 · C1.C1Excel Namespace

Columns Gets a reference to sheet's column collection.


DefaultColumnWidth Gets or sets the default row height for the sheet (in
twips).
DefaultRowHeight Gets or sets the default row height for the sheet (in
twips).
Locked Gets or sets a value that determines if the sheet is locked
for editing.
MergedCells Gets a XLCellRangeCollection that contains the
collection of cells that are merged on the sheet.
Name Gets or sets the name of the XLSheet.
PrintSettings Gets or sets an XLPrintSettings object that controls
how the sheet is printed.
Rows Gets a reference to sheet's row collection.
ShowGridLines Gets or sets whether Excel should show the grid lines
when displaying the sheet.
Visible Gets or sets the sheet's visibility.
See Also
XLSheet Class | C1.C1Excel Namespace

XLSheet.Book Property
Gets a reference to the C1XLBook that owns the sheet.

[Visual Basic]
Public ReadOnly Property Book As C1XLBook

[C#]
public C1XLBook Book {get;}

[Delphi]
public property Book: C1XLBook read get_Book;
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.Columns Property
Gets a reference to sheet's column collection.

[Visual Basic]
Public ReadOnly Property Columns As XLColumnCollection

[C#]
public XLColumnCollection Columns {get;}

[Delphi]
public property Columns: XLColumnCollection read get_Columns;
XLSheet.DefaultColumnWidth Property · 105

See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.DefaultColumnWidth Property
Gets or sets the default row height for the sheet (in twips).

[Visual Basic]
Public Property DefaultColumnWidth As Integer

[C#]
public int DefaultColumnWidth {get;set;}

[Delphi]
public property DefaultColumnWidth: Int32 read get_DefaultColumnWidth
write set_DefaultColumnWidth;
Remarks
You can set the width of individual rows using the XLColumn class. Any columns that do not have a custom
width assigned to them will be displayed using the sheet's DefaultColumnWidth.
The DefaultColumnWidth property is expressed in twips (1/20th of a point), rather than pixels. This allows
sheets to maintain their aspect regardless of the resolution of the display.
To convert twips into pixels, use the TwipsToPixels method in C1XLBook. To convert pixels into twips, use
the PixelsToTwips method.
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.DefaultRowHeight Property
Gets or sets the default row height for the sheet (in twips).

[Visual Basic]
Public Property DefaultRowHeight As Integer

[C#]
public int DefaultRowHeight {get;set;}

[Delphi]
public property DefaultRowHeight: Int32 read get_DefaultRowHeight write
set_DefaultRowHeight;
Remarks
You can set the height of individual rows using the XLRow class. Any rows that do not have a custom height
assigned to them will be displayed using the sheet's DefaultRowHeight.
The DefaultRowHeight property is expressed in twips (1/20th of a point), rather than pixels. This allows
sheets to maintain their aspect regardless of the resolution of the display.
To convert twips into pixels, use the TwipsToPixels method in C1XLBook. To convert pixels into twips, use
the PixelsToTwips method.
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace
106 · C1.C1Excel Namespace

XLSheet.Locked Property
Gets or sets a value that determines if the sheet is locked for editing.

[Visual Basic]
Public Property Locked As Boolean

[C#]
public bool Locked {get;set;}

[Delphi]
public property Locked: Boolean read get_Locked write set_Locked;
Remarks
Sheets and styles can be locked. By default, sheets are unlocked and styles are locked. This combination allows
users to edit the cells in Excel.
To protect a cell against editing in Excel, both the sheet and the cell style must have the Locked property set to
true.
To lock most cells on a sheet and allow editing of only a few cells, lock the sheet, then create an unlocked style
and assign it to the cells that should be editable.
Example
The code below creates a data entry sheet. Most cells are locked, except for the ones where the user is
supposed to enter data.
• Visual Basic
' start with a single locked sheet
_c1xl.Clear()
Dim sheet As XLSheet = _c1xl.Sheets(0)
sheet.Locked = True

' create an unlocked style


Dim dataEnTry As XLStyle = New XLStyle(_c1xl)
dataEnTry.Locked = False
dataEnTry.BackColor = Color.Beige

' create data entry titles


sheet(0,0).Value = "Name:"
sheet(1,0).Value = "Address:"
sheet(2,0).Value = "Phone #:"

' create data enTry cells (unlocked)


sheet(0,1).Style = dataEnTry
sheet(1,1).Style = dataEnTry
sheet(2,1).Style = dataEnTry

' save the book


_c1xl.Save("c:\temp\Protected.xls")
• C#
// start with a single locked sheet
_c1xl.Clear();
XLSheet sheet = _c1xl.Sheets[0];
sheet.Locked = true;

// create an unlocked style


XLSheet.MergedCells Property · 107

XLStyle dataEntry = new XLStyle(_c1xl);


dataEntry.Locked = false;
dataEntry.BackColor = Color.Beige;

// create data entry titles


sheet[0,0].Value = "Name:";
sheet[1,0].Value = "Address:";
sheet[2,0].Value = "Phone #:";

// create data entry cells (unlocked)


sheet[0,1].Style = dataEntry;
sheet[1,1].Style = dataEntry;
sheet[2,1].Style = dataEntry;

// save the book


_c1xl.Save(@"c:\temp\Protected.xls");
• Delphi
var
sheet: XLSheet;
dataEntry: XLStyle;
begin
// start with a single locked sheet
_c1xl.Clear;
sheet := _c1xl.Sheets[0];
sheet.Locked := true;

// create an unlocked style


dataEntry := XLStyle.Create(_c1xl);
dataEntry.Locked := false;
dataEntry.BackColor := Color.Beige;

// create data entry titles


sheet[0,0].Value := "Name:";
sheet[1,0].Value := "Address:";
sheet[2,0].Value := "Phone #:";

// create data entry cells (unlocked)


sheet[0,1].Style := dataEntry;
sheet[1,1].Style := dataEntry;
sheet[2,1].Style := dataEntry;

// save the book


_c1xl.Save('c:\temp\Protected.xls');
end;
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.MergedCells Property
Gets a XLCellRangeCollection that contains the collection of cells that are merged on the sheet.

[Visual Basic]
Public ReadOnly Property MergedCells As XLCellRangeCollection
108 · C1.C1Excel Namespace

[C#]
public XLCellRangeCollection MergedCells {get;}

[Delphi]
public property MergedCells: XLCellRangeCollection read get_MergedCells;
Remarks
The collection has methods for inspecting, adding, or clearing merged ranges in a sheet. Each merged range is
represented by a XLCellRange object.
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.Name Property
Gets or sets the name of the XLSheet.

[Visual Basic]
Public Property Name As String

[C#]
public string Name {get;set;}

[Delphi]
public property Name: String read get_Name write set_Name;
Remarks
When you open a workbook in Excel, the sheet names appear in the tabs below the work area.
Sheet names can be used as indexers, so they should be unique.
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.PrintSettings Property
Gets or sets an XLPrintSettings object that controls how the sheet is printed.

[Visual Basic]
Public Property PrintSettings As XLPrintSettings

[C#]
public XLPrintSettings PrintSettings {get;set;}

[Delphi]
public property PrintSettings: XLPrintSettings read get_PrintSettings
write set_PrintSettings;
Example
The code below creates a header for the sheet and sets the orientation to landscape:
• Visual Basic
Dim pp As XLPrintSettings = sheet.PrintSettings()
pp.Landscape = True
pp.Header = "&LLeft Header&CCenter Header&RRight Header"
XLSheet.Rows Property · 109

• C#
XLPrintSettings pp = sheet.PrintSettings();
pp.Landscape = true;
pp.Header = "&LLeft Header&CCenter Header&RRight Header";
• Delphi
var
pp: XLPrintSettings;
begin
pp := sheet.PrintSettings;
pp.Landscape := true;
pp.Header := '&LLeft Header&CCenter Header&RRight Header';
end;
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.Rows Property
Gets a reference to sheet's row collection.

[Visual Basic]
Public ReadOnly Property Rows As XLRowCollection

[C#]
public XLRowCollection Rows {get;}

[Delphi]
public property Rows: XLRowCollection read get_Rows;
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.ShowGridLines Property
Gets or sets whether Excel should show the grid lines when displaying the sheet.

[Visual Basic]
Public Property ShowGridLines As Boolean

[C#]
public bool ShowGridLines {get;set;}

[Delphi]
public property ShowGridLines: Boolean read get_ShowGridLines write
set_ShowGridLines;
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.Visible Property
Gets or sets the sheet's visibility.

[Visual Basic]
Public Property Visible As Boolean
110 · C1.C1Excel Namespace

[C#]
public bool Visible {get;set;}

[Delphi]
public property Visible: Boolean read get_Visible write set_Visible;
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet Methods
The methods of the XLSheet class are listed here. For a complete list of XLSheet class members, see the
XLSheet Members topic.
Public Methods
Clone Creates a copy of this sheet.
GetCell Gets a reference to a cell at the specified coordinates, or
null of the cell doesn't exist.
See Also
XLSheet Class | C1.C1Excel Namespace

XLSheet.Clone Method
Creates a copy of this sheet.

[Visual Basic]
Public Function Clone() As XLSheet

[C#]
public XLSheet Clone()

[Delphi]
public function Clone(): XLSheet;
Return Value
A new XLSheet object with the same contents and formatting as this sheet.
Remarks
After cloning a sheet, you must rename it and then add it to the book (duplicate names are not allowed).
This method is useful for applications that generate books with a large number of similar sheets.
Example
The code below loads a book that contains a template sheet, creates 12 copies of that sheet, removes the
template sheet, then saves the file with a new name.

// load book with template sheet


_c1xl.Load(@"c:\temp\template.xls");

// create 12 copies of the template sheet


XLSheet templateSheet = _c1xl.Sheets["Template"];
for (int month = 1; month <= 12; month++)
{
XLSheet.GetCell Method · 111

XLSheet newSheet = templateSheet.Clone();


newSheet.Name = month.ToString(); // rename clone
newSheet[0,0].Value = month; // make changes
_c1xl.Sheets.Add(newSheet); // add clone to book
}

// remove the template sheet and save with new name


_c1xl.Sheets.Remove("Template");
_c1xl.Save(@"C:\temp\expense_report.xls");

See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace

XLSheet.GetCell Method
Gets a reference to a cell at the specified coordinates, or null of the cell doesn't exist.

[Visual Basic]
Public Function GetCell( _
ByVal rowIndex As Integer, _
ByVal colIndex As Integer _
) As XLCell

[C#]
public XLCell GetCell(
int rowIndex,
int colIndex
);

[Delphi]
public function GetCell(
rowIndex: Int32;
colIndex: Int32
): XLCell;
Parameters
rowIndex
Index of the row.
colIndex
Index of the column.
Return Value
A reference to the XLCell object at the specified coordinates, or null if there is no cell at the specified position.
Remarks
To populate new sheets, use the Sheets indexer instead.
The indexer will automatically create new rows, columns, and cells as needed, and will never return null.
See Also
XLSheet Class | XLSheet Members | C1.C1Excel Namespace
112 · C1.C1Excel Namespace

XLSheetCollection Class
Collection of XLSheet objects that represent the individual worksheets in a C1XLBook.
For a list of all members of this type, see XLSheetCollection Members.
System.Object
C1.C1Excel.XLSheetCollection

[Visual Basic]
Public Class XLSheetCollection
Implements ICollection, IEnumerable

[C#]
public class XLSheetCollection : ICollection, IEnumerable

[Delphi]
type XLSheetCollection = class (TObject, ICollection, IEnumerable);
Remarks
Provides methods and properties for counting, enumerating, adding, and removing sheets from the workbook.
Example
Use the C1XLBook Sheets property to get the book's sheet collection. For example, the code below gets a
reference to the first sheet on the book, then prints the sheet's name:
• Visual Basic
Dim book As New C1XLBook()
Dim sheet As XLSheet = book.Sheets(0)
Console.WriteLine(sheet.Name)
• C#
C1XLBook book = new C1XLBook();
XLSheet sheet = book.Sheets[0];
Console.WriteLine(sheet.Name);
• Delphi
var
sheet: XLSheet;
book: C1XLBook;
begin
book := C1XLBook.Create;
sheet := book.Sheets[0];
Console.WriteLine(sheet.Name);
end;
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLSheetCollection Members | C1.C1Excel Namespace

XLSheetCollection Members
XLSheetCollection overview
XLSheetCollection.Book Property · 113

Public Properties
Book Gets a reference to the C1XLBook that owns the
collection.
Count Gets the number of XLSheet objects in the collection.
Item Overloaded. Gets the XLSheet at a given position in the
collection.
SelectedIndex Gets or sets the index of the sheet that is selected when
the C1XLBook file is loaded into Excel.
Public Methods
Add Overloaded. Creates a new XLSheet and appends it to
the collection.
Clear Removes all items from the collection.
Contains Overloaded. Determines whether the collection
contains a specific XLSheet object.
IndexOf Overloaded. Gets the index of a given XLSheet in the
collection.
Insert Overloaded. Creates a new XLSheet and inserts it at a
specific position in the collection.
Remove Overloaded. Removes an XLSheet from the collection.
RemoveAt Removes the XLSheet at a specific index from the
collection.
See Also
XLSheetCollection Class | C1.C1Excel Namespace

XLSheetCollection Properties
The properties of the XLSheetCollection class are listed here. For a complete list of XLSheetCollection class
members, see the XLSheetCollection Members topic.
Public Properties
Book Gets a reference to the C1XLBook that owns the
collection.
Count Gets the number of XLSheet objects in the collection.
Item Overloaded. Gets the XLSheet at a given position in the
collection.
SelectedIndex Gets or sets the index of the sheet that is selected when
the C1XLBook file is loaded into Excel.
See Also
XLSheetCollection Class | C1.C1Excel Namespace

XLSheetCollection.Book Property
Gets a reference to the C1XLBook that owns the collection.
114 · C1.C1Excel Namespace

[Visual Basic]
Public ReadOnly Property Book As C1XLBook

[C#]
public C1XLBook Book {get;}

[Delphi]
public property Book: C1XLBook read get_Book;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace

XLSheetCollection.Count Property
Gets the number of XLSheet objects in the collection.

[Visual Basic]
Public ReadOnly Property Count As Integer

[C#]
public int Count {get;}

[Delphi]
public property Count: Int32 read get_Count;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace

XLSheetCollection.Item Property
Overload List
Gets the XLSheet at a given position in the collection.
[Visual Basic] Overloads Public Default ReadOnly Property Item(Integer) As XLSheet
[C#] public XLSheet this[int]{get;}
[Delphi] public property Item[index: Int32]: XLSheet read get_Item;
Gets the XLSheet with the given name (case-insensitive).
[Visual Basic] Overloads Public Default ReadOnly Property Item(String) As XLSheet
[C#] public XLSheet this[string]{get;}
[Delphi] public property Item[name: String]: XLSheet read get_Item;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace

XLSheetCollection.Item Property (Int32)


Gets the XLSheet at a given position in the collection.

[Visual Basic]
Public Default ReadOnly Property Item( _
ByVal index As Integer _
) As XLSheet
XLSheetCollection.SelectedIndex Property · 115

[C#]
public XLSheet this[
int index
] {get;}

[Delphi]
public property Item[
index: Int32
]: XLSheet read get_Item;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace | XLSheetCollection.Item
Overload List

XLSheetCollection.Item Property (String)


Gets the XLSheet with the given name (case-insensitive).

[Visual Basic]
Public Default ReadOnly Property Item( _
ByVal name As String _
) As XLSheet

[C#]
public XLSheet this[
string name
] {get;}

[Delphi]
public property Item[
name: String
]: XLSheet read get_Item;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace | XLSheetCollection.Item
Overload List

XLSheetCollection.SelectedIndex Property
Gets or sets the index of the sheet that is selected when the C1XLBook file is loaded into Excel.

[Visual Basic]
Public Property SelectedIndex As Integer

[C#]
public int SelectedIndex {get;set;}

[Delphi]
public property SelectedIndex: Int32 read get_SelectedIndex write
set_SelectedIndex;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace
116 · C1.C1Excel Namespace

XLSheetCollection Methods
The methods of the XLSheetCollection class are listed here. For a complete list of XLSheetCollection class
members, see the XLSheetCollection Members topic.
Public Methods
Add Overloaded. Creates a new XLSheet and appends it to
the collection.
Clear Removes all items from the collection.
Contains Overloaded. Determines whether the collection
contains a specific XLSheet object.
IndexOf Overloaded. Gets the index of a given XLSheet in the
collection.
Insert Overloaded. Creates a new XLSheet and inserts it at a
specific position in the collection.
Remove Overloaded. Removes an XLSheet from the collection.
RemoveAt Removes the XLSheet at a specific index from the
collection.
See Also
XLSheetCollection Class | C1.C1Excel Namespace

XLSheetCollection.Add Method
Overload List
Creates a new XLSheet and appends it to the collection.
[Visual Basic] Overloads Public Function Add() As XLSheet
[C#] public XLSheet Add();
[Delphi] public function Add() : XLSheet; overload;
Creates a new XLSheet with a given name and appends it to the collection.
[Visual Basic] Overloads Public Function Add(String) As XLSheet
[C#] public XLSheet Add(string);
[Delphi] public function Add(String) : XLSheet; overload;
Appends an existing XLSheet to the collection.
[Visual Basic] Overloads Public Function Add(XLSheet) As XLSheet
[C#] public XLSheet Add(XLSheet);
[Delphi] public function Add(XLSheet) : XLSheet; overload;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace

XLSheetCollection.Add Method ()
Creates a new XLSheet and appends it to the collection.

[Visual Basic]
Overloads Public Function Add() As XLSheet
XLSheetCollection.Add Method · 117

[C#]
public XLSheet Add()

[Delphi]
public function Add(): XLSheet; overload;
Return Value
A reference to the new XLSheet object.
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace | XLSheetCollection.Add
Overload List

XLSheetCollection.Add Method (String)


Creates a new XLSheet with a given name and appends it to the collection.

[Visual Basic]
Overloads Public Function Add( _
ByVal name As String _
) As XLSheet

[C#]
public XLSheet Add(
string name
);

[Delphi]
public function Add(
name: String
): XLSheet; overload;
Parameters
name
The name of the new XLSheet.
Return Value
A reference to the new XLSheet object.
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace | XLSheetCollection.Add
Overload List

XLSheetCollection.Add Method (XLSheet)


Appends an existing XLSheet to the collection.

[Visual Basic]
Overloads Public Function Add( _
ByVal sheet As XLSheet _
) As XLSheet
118 · C1.C1Excel Namespace

[C#]
public XLSheet Add(
XLSheet sheet
);

[Delphi]
public function Add(
sheet: XLSheet
): XLSheet; overload;
Parameters
sheet
The object to add to the collection.
Return Value
A reference to the object that was added to the collection (in this case, always the sheet parameter).
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace | XLSheetCollection.Add
Overload List

XLSheetCollection.Clear Method
Removes all items from the collection.

[Visual Basic]
Public Sub Clear()

[C#]
public void Clear()

[Delphi]
public procedure Clear();
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace

XLSheetCollection.Contains Method
Overload List
Determines whether the collection contains an XLSheet object with a given name.
[Visual Basic] Overloads Public Function Contains(String) As Boolean
[C#] public bool Contains(string);
[Delphi] public function Contains(String) : Boolean; overload;
Determines whether the collection contains a specific XLSheet object.
[Visual Basic] Overloads Public Function Contains(XLSheet) As Boolean
[C#] public bool Contains(XLSheet);
[Delphi] public function Contains(XLSheet) : Boolean; overload;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace
XLSheetCollection.Contains Method · 119

XLSheetCollection.Contains Method (String)


Determines whether the collection contains an XLSheet object with a given name.

[Visual Basic]
Overloads Public Function Contains( _
ByVal sheetName As String _
) As Boolean

[C#]
public bool Contains(
string sheetName
);

[Delphi]
public function Contains(
sheetName: String
): Boolean; overload;
Parameters
sheetName
The name of the sheet to look for (case-insensitive).
Return Value
True if the collection contains an XLSheet, with the given sheetName, False otherwise.
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace |
XLSheetCollection.Contains Overload List

XLSheetCollection.Contains Method (XLSheet)


Determines whether the collection contains a specific XLSheet object.

[Visual Basic]
Overloads Public Function Contains( _
ByVal sheet As XLSheet _
) As Boolean

[C#]
public bool Contains(
XLSheet sheet
);

[Delphi]
public function Contains(
sheet: XLSheet
): Boolean; overload;
Parameters
sheet
The object to look for in the collection.
120 · C1.C1Excel Namespace

Return Value
True if the collection contains the object, False otherwise.
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace |
XLSheetCollection.Contains Overload List

XLSheetCollection.IndexOf Method
Overload List
Gets the position of the sheet with the specified name in the collection.
[Visual Basic] Overloads Public Function IndexOf(String) As Integer
[C#] public int IndexOf(string);
[Delphi] public function IndexOf(String) : Int32; overload;
Gets the index of a given XLSheet in the collection.
[Visual Basic] Overloads Public Function IndexOf(XLSheet) As Integer
[C#] public int IndexOf(XLSheet);
[Delphi] public function IndexOf(XLSheet) : Int32; overload;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace

XLSheetCollection.IndexOf Method (String)


Gets the position of the sheet with the specified name in the collection.

[Visual Basic]
Overloads Public Function IndexOf( _
ByVal name As String _
) As Integer

[C#]
public int IndexOf(
string name
);

[Delphi]
public function IndexOf(
name: String
): Int32; overload;
Parameters
name
Name of the object to look for (case-insensitive).
Return Value
The index of the sheet in the collection, or -1 if the sheet can't be found in the collection.
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace |
XLSheetCollection.IndexOf Overload List
XLSheetCollection.Insert Method · 121

XLSheetCollection.IndexOf Method (XLSheet)


Gets the index of a given XLSheet in the collection.

[Visual Basic]
Overloads Public Function IndexOf( _
ByVal sheet As XLSheet _
) As Integer

[C#]
public int IndexOf(
XLSheet sheet
);

[Delphi]
public function IndexOf(
sheet: XLSheet
): Int32; overload;
Parameters
sheet
The object to look for.
Return Value
The index of the object in the collection, or -1 if the object is not a member of the collection.
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace |
XLSheetCollection.IndexOf Overload List

XLSheetCollection.Insert Method
Overload List
Creates a new XLSheet and inserts it at a specific position in the collection.
[Visual Basic] Overloads Public Function Insert(Integer) As XLSheet
[C#] public XLSheet Insert(int);
[Delphi] public function Insert(Int32) : XLSheet; overload;
Inserts an XLSheet object into the collection at the specified position.
[Visual Basic] Overloads Public Function Insert(Integer, XLSheet) As XLSheet
[C#] public XLSheet Insert(int, XLSheet);
[Delphi] public function Insert(Int32; XLSheet) : XLSheet; overload;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace

XLSheetCollection.Insert Method (Int32)


Creates a new XLSheet and inserts it at a specific position in the collection.
122 · C1.C1Excel Namespace

[Visual Basic]
Overloads Public Function Insert( _
ByVal index As Integer _
) As XLSheet

[C#]
public XLSheet Insert(
int index
);

[Delphi]
public function Insert(
index: Int32
): XLSheet; overload;
Parameters
index
Index where the new XLSheet will be added.
Return Value
A reference to the new XLSheet object.
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace |
XLSheetCollection.Insert Overload List

XLSheetCollection.Insert Method (Int32, XLSheet)


Inserts an XLSheet object into the collection at the specified position.

[Visual Basic]
Overloads Public Function Insert( _
ByVal index As Integer, _
ByVal sheet As XLSheet _
) As XLSheet

[C#]
public XLSheet Insert(
int index,
XLSheet sheet
);

[Delphi]
public function Insert(
index: Int32;
sheet: XLSheet
): XLSheet; overload;
Parameters
index
Position where the item will be inserted.
sheet
XLSheet object to add to the collection.
XLSheetCollection.Remove Method · 123

Return Value
A reference to the object that was added to the collection (in this case, always the sheet parameter).
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace |
XLSheetCollection.Insert Overload List

XLSheetCollection.Remove Method
Overload List
Removes the XLSheet with the specified name from the collection.
[Visual Basic] Overloads Public Sub Remove(String)
[C#] public void Remove(string);
[Delphi] public procedure Remove(String); overload;
Removes an XLSheet from the collection.
[Visual Basic] Overloads Public Sub Remove(XLSheet)
[C#] public void Remove(XLSheet);
[Delphi] public procedure Remove(XLSheet); overload;
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace

XLSheetCollection.Remove Method (String)


Removes the XLSheet with the specified name from the collection.

[Visual Basic]
Overloads Public Sub Remove( _
ByVal name As String _
)

[C#]
public void Remove(
string name
);

[Delphi]
public procedure Remove(
name: String
); overload;
Parameters
name
Name of the sheet to remove from the collection (case-insensitive).
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace |
XLSheetCollection.Remove Overload List
124 · C1.C1Excel Namespace

XLSheetCollection.Remove Method (XLSheet)


Removes an XLSheet from the collection.

[Visual Basic]
Overloads Public Sub Remove( _
ByVal sheet As XLSheet _
)

[C#]
public void Remove(
XLSheet sheet
);

[Delphi]
public procedure Remove(
sheet: XLSheet
); overload;
Parameters
sheet
The XLSheet object to remove from the collection.
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace |
XLSheetCollection.Remove Overload List

XLSheetCollection.RemoveAt Method
Removes the XLSheet at a specific index from the collection.

[Visual Basic]
Public Sub RemoveAt( _
ByVal index As Integer _
)

[C#]
public void RemoveAt(
int index
);

[Delphi]
public procedure RemoveAt(
index: Int32
);
Parameters
index
Index of the object to remove from the collection.
See Also
XLSheetCollection Class | XLSheetCollection Members | C1.C1Excel Namespace
XLStyle Class · 125

XLStyle Class
Contains style elements used to define the appearance of the cells.
For a list of all members of this type, see XLStyle Members.
System.Object
C1.C1Excel.XLStyle

[Visual Basic]
Public Class XLStyle
Implements ICloneable

[C#]
public class XLStyle : ICloneable

[Delphi]
type XLStyle = class (TObject, ICloneable);
Remarks
Each XLStyle object may define one or more of the following elements: font, format, background color,
background pattern, foreground color, alignment, text direction, and word wrapping.
When displaying a cell, Excel combines the row, column, and cell styles and merges the style elements defined
in each one in order to determine how the cell should be displayed. The precedence of the styles is: (1) cell, (2)
row, (3) column, (4) default style.
Every XLStyle belongs to a C1XLBook, and may be assigned to one or more XLRow, XLColumn, and
XLCell objects through their Style property.
Namespace: C1.C1Excel
Assembly: C1.C1Excel.2 (in C1.C1Excel.2.dll)
See Also
XLStyle Members | C1.C1Excel Namespace

XLStyle Members
XLStyle overview
Public Constructors
XLStyle Constructor Creates a new instance of XLStyle and adds it to the
specified C1XLBook.
Public Properties
AlignHorz Gets or sets the horizontal alignment for this XLStyle.
AlignVert Gets or sets the vertical alignment for this XLStyle.
BackColor Gets or sets the background color for this XLStyle.
BackPattern Gets or sets the background pattern for this XLStyle.
BorderBottom Gets or sets the line style used to draw the bottom
border.
BorderColorBottom Gets or sets the color used to draw the bottom border.
126 · C1.C1Excel Namespace

BorderColorLeft Gets or sets the color used to draw the left border.
BorderColorRight Gets or sets the color used to draw the right border.
BorderColorTop Gets or sets the color used to draw the top border.
BorderLeft Gets or sets the line style used to draw the left border.
BorderRight Gets or sets the line style used to draw the right border.
BorderTop Gets or sets the line style used to draw the top border.
Diagonal Gets or sets which diagonal lines to display (none,
forward, backward).
DiagonalColor Gets or sets the color used to draw the diagonal lines.
DiagonalStyle Gets or sets the line style used to draw the diagonal
lines.
Font Gets or sets the font for this XLStyle.
ForeColor Gets or sets the foreground color for this XLStyle.
Format Gets or sets the format associated with this XLStyle.
Locked Gets or sets whether the cell should be locked for
editing when the XLSheet is protected.
PatternColor Gets or sets the color of the background pattern for this
XLStyle.
Rotation Gets or sets the rotation for this XLStyle, in degrees.
WordWrap Gets or sets whether this XLStyle causes cell contents
to wrap.
Public Methods
Clone Creates a new XLStyle object that is a copy of the
current instance.
Equals Overriden. Determines whether two XLStyle objects
are equivalent.
FormatDotNetToXL Overloaded. Converts a .NET-style format string into
an Excel format string.
FormatXLToDotNet Converts a Excel-style format string into a .NET-style
format string.
GetHashCode Overriden. Serves as a hash function suitable for use in
hashing algorithms and data structures like a hash table.
SetBorderColor Sets the border color for this XLStyle.
SetBorderStyle Sets the border style for this XLStyle.
See Also
XLStyle Class | C1.C1Excel Namespace

XLStyle Constructor
Creates a new instance of XLStyle and adds it to the specified C1XLBook.
XLStyle Properties · 127

[Visual Basic]
Public Function New( _
ByVal book As C1XLBook _
)

[C#]
public XLStyle(
C1XLBook book
);

[Delphi]
public constructor Create(
book: C1XLBook
); overload;
Parameters
book
Parent C1XLBook.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle Properties
The properties of the XLStyle class are listed here. For a complete list of XLStyle class members, see the
XLStyle Members topic.
Public Properties
AlignHorz Gets or sets the horizontal alignment for this XLStyle.
AlignVert Gets or sets the vertical alignment for this XLStyle.
BackColor Gets or sets the background color for this XLStyle.
BackPattern Gets or sets the background pattern for this XLStyle.
BorderBottom Gets or sets the line style used to draw the bottom
border.
BorderColorBottom Gets or sets the color used to draw the bottom border.
BorderColorLeft Gets or sets the color used to draw the left border.
BorderColorRight Gets or sets the color used to draw the right border.
BorderColorTop Gets or sets the color used to draw the top border.
BorderLeft Gets or sets the line style used to draw the left border.
BorderRight Gets or sets the line style used to draw the right border.
BorderTop Gets or sets the line style used to draw the top border.
Diagonal Gets or sets which diagonal lines to display (none,
forward, backward).
DiagonalColor Gets or sets the color used to draw the diagonal lines.
DiagonalStyle Gets or sets the line style used to draw the diagonal
lines.
128 · C1.C1Excel Namespace

Font Gets or sets the font for this XLStyle.


ForeColor Gets or sets the foreground color for this XLStyle.
Format Gets or sets the format associated with this XLStyle.
Locked Gets or sets whether the cell should be locked for
editing when the XLSheet is protected.
PatternColor Gets or sets the color of the background pattern for this
XLStyle.
Rotation Gets or sets the rotation for this XLStyle, in degrees.
WordWrap Gets or sets whether this XLStyle causes cell contents
to wrap.
See Also
XLStyle Class | C1.C1Excel Namespace

XLStyle.AlignHorz Property
Gets or sets the horizontal alignment for this XLStyle.

[Visual Basic]
Public Property AlignHorz As XLAlignHorzEnum

[C#]
public XLAlignHorzEnum AlignHorz {get;set;}

[Delphi]
public property AlignHorz: XLAlignHorzEnum read get_AlignHorz write
set_AlignHorz;
Remarks
Set the AlignHorz property to XLAlignHorzEnum.Undefined to suppress this style element and use the
default horizontal alignment instead ( XLAlignHorzEnum.General).
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.AlignVert Property
Gets or sets the vertical alignment for this XLStyle.

[Visual Basic]
Public Property AlignVert As XLAlignVertEnum

[C#]
public XLAlignVertEnum AlignVert {get;set;}

[Delphi]
public property AlignVert: XLAlignVertEnum read get_AlignVert write
set_AlignVert;
XLStyle.BackColor Property · 129

Remarks
Set the AlignVert property to XLAlignVertEnum.Undefined to suppress this style element and use the default
horizontal alignment instead ( XLAlignVertEnum.Bottom).
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.BackColor Property
Gets or sets the background color for this XLStyle.

[Visual Basic]
Public Property BackColor As Color

[C#]
public Color BackColor {get;set;}

[Delphi]
public property BackColor: Color read get_BackColor write set_BackColor;
Remarks
Set the BackColor property to Color.Transparent to suppress this style element and use the default
background color instead (white).
All colors on the C1XLBook are mapped onto a palette. This means that is you assign colors to styles, save
the book, and then load it back, you probably won't get exactly the same colors used when the book was
created. You will get a fairly close approximation though.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.BackPattern Property
Gets or sets the background pattern for this XLStyle.

[Visual Basic]
Public Property BackPattern As XLPatternEnum

[C#]
public XLPatternEnum BackPattern {get;set;}

[Delphi]
public property BackPattern: XLPatternEnum read get_BackPattern write
set_BackPattern;
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.BorderBottom Property
Gets or sets the line style used to draw the bottom border.

[Visual Basic]
Public Property BorderBottom As XLLineStyleEnum
130 · C1.C1Excel Namespace

[C#]
public XLLineStyleEnum BorderBottom {get;set;}

[Delphi]
public property BorderBottom: XLLineStyleEnum read get_BorderBottom write
set_BorderBottom;
Remarks
Use the SetBorderStyle method to set all borders at once.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.BorderColorBottom Property
Gets or sets the color used to draw the bottom border.

[Visual Basic]
Public Property BorderColorBottom As Color

[C#]
public Color BorderColorBottom {get;set;}

[Delphi]
public property BorderColorBottom: Color read get_BorderColorBottom write
set_BorderColorBottom;
Remarks
Use the SetBorderColor method to set all borders at once.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.BorderColorLeft Property
Gets or sets the color used to draw the left border.

[Visual Basic]
Public Property BorderColorLeft As Color

[C#]
public Color BorderColorLeft {get;set;}

[Delphi]
public property BorderColorLeft: Color read get_BorderColorLeft write
set_BorderColorLeft;
Remarks
Use the SetBorderColor method to set all borders at once.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace
XLStyle.BorderColorRight Property · 131

XLStyle.BorderColorRight Property
Gets or sets the color used to draw the right border.

[Visual Basic]
Public Property BorderColorRight As Color

[C#]
public Color BorderColorRight {get;set;}

[Delphi]
public property BorderColorRight: Color read get_BorderColorRight write
set_BorderColorRight;
Remarks
Use the SetBorderColor method to set all borders at once.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.BorderColorTop Property
Gets or sets the color used to draw the top border.

[Visual Basic]
Public Property BorderColorTop As Color

[C#]
public Color BorderColorTop {get;set;}

[Delphi]
public property BorderColorTop: Color read get_BorderColorTop write
set_BorderColorTop;
Remarks
Use the SetBorderColor method to set all borders at once.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.BorderLeft Property
Gets or sets the line style used to draw the left border.

[Visual Basic]
Public Property BorderLeft As XLLineStyleEnum

[C#]
public XLLineStyleEnum BorderLeft {get;set;}

[Delphi]
public property BorderLeft: XLLineStyleEnum read get_BorderLeft write
set_BorderLeft;
132 · C1.C1Excel Namespace

Remarks
Use the SetBorderStyle method to set all borders at once.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.BorderRight Property
Gets or sets the line style used to draw the right border.

[Visual Basic]
Public Property BorderRight As XLLineStyleEnum

[C#]
public XLLineStyleEnum BorderRight {get;set;}

[Delphi]
public property BorderRight: XLLineStyleEnum read get_BorderRight write
set_BorderRight;
Remarks
Use the SetBorderStyle method to set all borders at once.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.BorderTop Property
Gets or sets the line style used to draw the top border.

[Visual Basic]
Public Property BorderTop As XLLineStyleEnum

[C#]
public XLLineStyleEnum BorderTop {get;set;}

[Delphi]
public property BorderTop: XLLineStyleEnum read get_BorderTop write
set_BorderTop;
Remarks
Use the SetBorderStyle method to set all borders at once.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.Diagonal Property
Gets or sets which diagonal lines to display (none, forward, backward).

[Visual Basic]
Public Property Diagonal As XLDiagonalFlags
XLStyle.DiagonalColor Property · 133

[C#]
public XLDiagonalFlags Diagonal {get;set;}

[Delphi]
public property Diagonal: XLDiagonalFlags read get_Diagonal write
set_Diagonal;
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.DiagonalColor Property
Gets or sets the color used to draw the diagonal lines.

[Visual Basic]
Public Property DiagonalColor As Color

[C#]
public Color DiagonalColor {get;set;}

[Delphi]
public property DiagonalColor: Color read get_DiagonalColor write
set_DiagonalColor;
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.DiagonalStyle Property
Gets or sets the line style used to draw the diagonal lines.

[Visual Basic]
Public Property DiagonalStyle As XLLineStyleEnum

[C#]
public XLLineStyleEnum DiagonalStyle {get;set;}

[Delphi]
public property DiagonalStyle: XLLineStyleEnum read get_DiagonalStyle
write set_DiagonalStyle;
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.Font Property
Gets or sets the font for this XLStyle.

[Visual Basic]
Public Property Font As Font

[C#]
public Font Font {get;set;}
134 · C1.C1Excel Namespace

[Delphi]
public property Font: Font read get_Font write set_Font;

Remarks
Set the Font property to null in order to suppress this style element and use the default font instead. The
default font is determined by the book's DefaultFont property.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.ForeColor Property
Gets or sets the foreground color for this XLStyle.

[Visual Basic]
Public Property ForeColor As Color

[C#]
public Color ForeColor {get;set;}

[Delphi]
public property ForeColor: Color read get_ForeColor write set_ForeColor;
Remarks
Set the ForeColor property to Color.Transparent to suppress this style element and use the default foreground
color instead (black).
All colors on the C1XLBook are mapped onto a palette. This means that is you assign colors to styles, save
the book, and then load it back, you probably won't get exactly the same colors used when the book was
created. You will get a fairly close approximation though.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.Format Property
Gets or sets the format associated with this XLStyle.

[Visual Basic]
Public Property Format As String

[C#]
public string Format {get;set;}

[Delphi]
public property Format: String read get_Format write set_Format;
Remarks
Excel uses formats similar, but not identical to .NET. Refer to the Excel documentation for details on how to
create format strings.
You can use the FormatXLToDotNet and FormatDotNetToXL (String, Type) methods to convert common
Excel format strings to and from .NET format strings.
XLStyle.Locked Property · 135

See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.Locked Property
Gets or sets whether the cell should be locked for editing when the XLSheet is protected.

[Visual Basic]
Public Property Locked As Boolean

[C#]
public bool Locked {get;set;}

[Delphi]
public property Locked: Boolean read get_Locked write set_Locked;
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.PatternColor Property
Gets or sets the color of the background pattern for this XLStyle.

[Visual Basic]
Public Property PatternColor As Color

[C#]
public Color PatternColor {get;set;}

[Delphi]
public property PatternColor: Color read get_PatternColor write
set_PatternColor;
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.Rotation Property
Gets or sets the rotation for this XLStyle, in degrees.

[Visual Basic]
Public Property Rotation As Integer

[C#]
public int Rotation {get;set;}

[Delphi]
public property Rotation: Int32 read get_Rotation write set_Rotation;
Remarks
This property should be set to values between 0 and 180, or 255, as explained below:
Zero means no rotation.
1-90 means 1 to 90 degrees counter-clockwise (90 causes text to be displayed in the vertical direction going up
the cell)
136 · C1.C1Excel Namespace

91-180 means 1 to 90 degrees clockwise (180 causes text to be displayed in the vertical direction going down
the cell)
255 causes letters are stacked top to bottom and not rotated.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.WordWrap Property
Gets or sets whether this XLStyle causes cell contents to wrap.

[Visual Basic]
Public Property WordWrap As Boolean

[C#]
public bool WordWrap {get;set;}

[Delphi]
public property WordWrap: Boolean read get_WordWrap write set_WordWrap;
Remarks
Cells that do not wrap will spill onto adjacent cells, and will be kept on a single line even if they contain line-
break characters.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle Methods
The methods of the XLStyle class are listed here. For a complete list of XLStyle class members, see the
XLStyle Members topic.
Public Methods
Clone Creates a new XLStyle object that is a copy of the
current instance.
Equals Overriden. Determines whether two XLStyle objects
are equivalent.
FormatDotNetToXL Overloaded. Converts a .NET-style format string into
an Excel format string.
FormatXLToDotNet Converts a Excel-style format string into a .NET-style
format string.
GetHashCode Overriden. Serves as a hash function suitable for use in
hashing algorithms and data structures like a hash table.
SetBorderColor Sets the border color for this XLStyle.
SetBorderStyle Sets the border style for this XLStyle.
See Also
XLStyle Class | C1.C1Excel Namespace
XLStyle.Clone Method · 137

XLStyle.Clone Method
Creates a new XLStyle object that is a copy of the current instance.

[Visual Basic]
Overridable Public Function Clone() As Object Implements ICloneable.Clone

[C#]
virtual public object Clone()

[Delphi]
public function Clone(): Object; virtual;
Implements
ICloneable.Clone
Return Value
A new XLStyle object that is a copy of the current instance.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.Equals Method
Determines whether two XLStyle objects are equivalent.

[Visual Basic]
Overrides Public Function Equals( _
ByVal obj As Object _
) As Boolean

[C#]
override public bool Equals(
object obj
);

[Delphi]
public function Equals(
obj: Object
): Boolean; override;
Parameters
obj
XLStyle object to compare to the current instance.
Return Value
True if the styles are equivalent, False otherwise.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace
138 · C1.C1Excel Namespace

XLStyle.FormatDotNetToXL Method
Overload List
Converts a .NET-style format string into an Excel format string.
[Visual Basic] Overloads Public Shared Function FormatDotNetToXL(String) As String
[C#] public static string FormatDotNetToXL(string);
[Delphi] public class function FormatDotNetToXL(String) : String; overload;

Converts a .NET-style format string into an Excel format string.


[Visual Basic] Overloads Public Shared Function FormatDotNetToXL(String, Type) As String
[C#] public static string FormatDotNetToXL(string, Type);
[Delphi] public class function FormatDotNetToXL(String; Type) : String; overload;
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.FormatDotNetToXL Method (String)


Converts a .NET-style format string into an Excel format string.

[Visual Basic]
Overloads Public Shared Function FormatDotNetToXL( _
ByVal fmt As String _
) As String

[C#]
public static string FormatDotNetToXL(
string fmt
);

[Delphi]
public class function FormatDotNetToXL(
fmt: String
): String; overload;
Parameters
fmt
.NET-style format to convert.
Return Value
An Excel-style format string.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace | XLStyle.FormatDotNetToXL Overload List

XLStyle.FormatDotNetToXL Method (String, Type)


Converts a .NET-style format string into an Excel format string.
XLStyle.FormatXLToDotNet Method · 139

[Visual Basic]
Overloads Public Shared Function FormatDotNetToXL( _
ByVal fmt As String, _
ByVal dataType As Type _
) As String

[C#]
public static string FormatDotNetToXL(
string fmt,
Type dataType
);

[Delphi]
public class function FormatDotNetToXL(
fmt: String;
dataType: Type
): String; overload;
Parameters
fmt
.NET-style format to convert.
dataType
Data type to be formatted.
Return Value
An Excel-style format string.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace | XLStyle.FormatDotNetToXL Overload List

XLStyle.FormatXLToDotNet Method
Converts a Excel-style format string into a .NET-style format string.

[Visual Basic]
Public Shared Function FormatXLToDotNet( _
ByVal fmt As String _
) As String

[C#]
public static string FormatXLToDotNet(
string fmt
);

[Delphi]
public class function FormatXLToDotNet(
fmt: String
): String;
Parameters
fmt
Excel-style format to convert.
140 · C1.C1Excel Namespace

Return Value
A .NET-style format string.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.GetHashCode Method
Serves as a hash function suitable for use in hashing algorithms and data structures like a hash table.

[Visual Basic]
Overrides Public Function GetHashCode() As Integer

[C#]
override public int GetHashCode()

[Delphi]
public function GetHashCode(): Int32; override;
Return Value
A hash code for the current XLStyle.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace

XLStyle.SetBorderColor Method
Sets the border color for this XLStyle.

[Visual Basic]
Public Sub SetBorderColor( _
ByVal color As Color _
)

[C#]
public void SetBorderColor(
Color color
);

[Delphi]
public procedure SetBorderColor(
color: Color
);
Parameters
color
Color used to draw the border.
Remarks
This method applies the setting to all four borders.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace
XLStyle.SetBorderStyle Method · 141

XLStyle.SetBorderStyle Method
Sets the border style for this XLStyle.

[Visual Basic]
Public Sub SetBorderStyle( _
ByVal style As XLLineStyleEnum _
)

[C#]
public void SetBorderStyle(
XLLineStyleEnum style
);

[Delphi]
public procedure SetBorderStyle(
style: XLLineStyleEnum
);
Parameters
style
Line style used to draw the border.
Remarks
This method applies the setting to all four borders.
See Also
XLStyle Class | XLStyle Members | C1.C1Excel Namespace
Index · 143

C1XLBook.PixelsToTwips method 42
C1XLBook.Save method 43
Index C1XLBook.Sheets property 40
C1XLBook.TwipsToPixels method 43
Cells 25
Center enumeration member 44, 45
2 CenterHorizontal property 82
CenterVertical property 82
2 assembly (C1.C1Excel) 35, 36, 37, 38, 39, 40, 41, 42,
Clear method 40, 59, 71, 98, 118
43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
Clone method 110, 137
57, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
ColumnCount property 52
71, 72, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
ColumnFrom property 52
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 98,
Columns property 104
99, 101, 102, 103, 104, 105, 106, 107, 108, 109,
ColumnTo property 52
110, 111, 112, 113, 114, 115, 116, 118, 120, 121,
Contains method 54, 60, 71, 98, 118
123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
Copies property 82
133, 134, 135, 136, 137, 138, 139, 140, 141
Count property 56, 68, 94, 114

A
D
Add method 57, 70, 96, 116
Dashed enumeration member 76
AlignHorz property 128
DefaultColumnWidth property 105
AlignVert property 128
DefaultFont property 39
AutoScale property 81
DefaultRowHeight property 105
Diagonal property 132
B DiagonalColor property 133
DiagonalCrosshatch enumeration member 76, 77
BackColor property 129
DiagonalStripe enumeration member 76, 77
BackPattern property 129
DiagonalStyle property 133
Backward enumeration member 75
Dotted enumeration member 76
BlackAndWhite property 81
Double enumeration member 76
Book property 64, 68, 91, 94, 104, 113
DraftQuality property 82
BorderBottom property 129
BorderColorBottom property 130
BorderColorLeft property 130 E
BorderColorRight property 131
Equals method 137
BorderColorTop property 131
BorderLeft property 131
BorderRight property 132 F
BorderTop property 132 Fill enumeration member 44
Bottom enumeration member 45
FitPagesAcross property 83
FitPagesDown property 83
C Font property 133
Footer property 84
C1Excel hierarchy (C1) 36
ForeColor property 134
C1Excel namespace (C1) 35
Format property 134
C1XLBook class 37
FormatDotNetToXL method 138
about C1XLBook class 37
FormatXLToDotNet method 139
all members 37
Forward enumeration member 75
constructor 38
Frozen property 68, 95
methods 40
properties 38
C1XLBook.C1XLBook constructor 38 G
C1XLBook.Clear method 40 General enumeration member 44
C1XLBook.DefaultFont property 39 GetCell method 111
C1XLBook.KeepFormulas property 39
GetHashCode method 140
C1XLBook.Load method 41
144 · Index

Gray06 enumeration member 76, 77 P


Gray12 enumeration member 76, 77
Gray25 enumeration member 76, 77 PaperKind property 87
Gray50 enumeration member 76, 77 PatternColor property 135
Gray75 enumeration member 76, 77 PixelsToTwips method 42
PrintGridlines property 87
PrintHeaders property 88
H PrintPagesInRows property 88
Hair enumeration member 76 PrintSettings property 108
Header property 84
Height property 91 R
HorizontalStripe enumeration member 76, 77
Hyperlink property 47 Remove method 61, 74, 101, 123
RemoveAt method 62, 75, 101, 124
ReverseDiagonalStripe enumeration member 76, 77
I Right enumeration member 44, 45
IndexOf method 60, 72, 98, 120 Rotation property 135
Insert method 61, 72, 99, 121 RowCount property 53
Intersects method 54 RowFrom property 53
IsEmpty property 52 Rows property 109
Item property 56, 68, 95, 114 RowTo property 53

J S
Justify enumeration member 44, 45 Save method 43
ScalingFactor property 88
SelectedIndex property 115
K Selection enumeration member 44, 45
KeepFormulas property 39 SetBorderColor method 140
SetBorderStyle method 141
Sheet property 57, 64, 69, 91, 96
L Sheets property 40
Landscape property 85 ShowGridLines property 109
Left enumeration member 44, 45 SlantedMediumDashDotted enumeration member 76
Licensing 9 Solid enumeration member 76, 77
Load method 41 StartPage property 89
Locked property 106, 135 Style property 48, 65, 92
Styles 25
Support
M ComponentOne Web Site 12
MarginBottom property 85 E-mail 12
MarginFooter property 86 peer-to-peer 13
MarginHeader property 86
MarginLeft property 86 T
MarginRight property 87
MarginTop property 87 Thick enumeration member 76
Medium enumeration member 76 ThickDiagonalCrosshatch enumeration member 76, 77
MediumDashDotDotted enumeration member 76 Thin enumeration member 76
MediumDashDotted enumeration member 76 ThinDashDotDotted enumeration member 76
MediumDashed enumeration member 76 ThinDashDotted enumeration member 76
MergedCells property 107 ThinDiagonalCrosshatch enumeration member 76, 77
ThinDiagonalStripe enumeration member 76, 77
ThinHorizontalCrosshatch enumeration member 76, 77
N ThinHorizontalStripe enumeration member 76, 77
Name property 108 ThinReverseDiagonalStripe enumeration member 76,
None enumeration member 75, 76, 77 77
Index · 145

ThinVerticalStripe enumeration member 76, 77 XLCellRangeCollection.Insert method 61


Top enumeration member 45 XLCellRangeCollection.Item property 56
TwipsToPixels method 43 XLCellRangeCollection.Remove method 61
XLCellRangeCollection.RemoveAt method 62
U XLCellRangeCollection.Sheet property 57
XLColumn class 63
Undefined enumeration member 44, 45 about XLColumn class 62
all members 63
V constructor 63
properties 64
Value property 48 XLColumn.Book property 64
VerticalStripe enumeration member 76, 77 XLColumn.Sheet property 64
Visible property 65, 92, 109 XLColumn.Style property 65
XLColumn.Visible property 65
W XLColumn.Width property 65
XLColumn.XLColumn constructor 63
Width property 65 XLColumnCollection class 67
WordWrap property 136 about XLColumnCollection class 66
all members 67
X methods 69
properties 67
XLAlignHorzEnum enumeration 44 XLColumnCollection.Add method 70
XLAlignVertEnum enumeration 45 XLColumnCollection.Book property 68
XLCell class 47 XLColumnCollection.Clear method 71
about XLCell class 45 XLColumnCollection.Contains method 71
all members 47 XLColumnCollection.Count property 68
properties 47 XLColumnCollection.Frozen property 68
XLCell.Hyperlink property 47 XLColumnCollection.IndexOf method 72
XLCell.Style property 48 XLColumnCollection.Insert method 72
XLCell.Value property 48 XLColumnCollection.Item property 68
XLCellRange class 49 XLColumnCollection.Remove method 74
about XLCellRange class 49 XLColumnCollection.RemoveAt method 75
all members 49 XLColumnCollection.Sheet property 69
constructor 50 XLDiagonalFlags enumeration 75
methods 54 XLLineStyleEnum enumeration 76
properties 51 XLPatternEnum enumeration 76
XLCellRange.ColumnCount property 52 XLPrintSettings class 78
XLCellRange.ColumnFrom property 52 about XLPrintSettings class 78
XLCellRange.ColumnTo property 52 all members 78
XLCellRange.Contains method 54 constructor 79
XLCellRange.Intersects method 54 properties 80
XLCellRange.IsEmpty property 52 XLPrintSettings.AutoScale property 81
XLCellRange.RowCount property 53 XLPrintSettings.BlackAndWhite property 81
XLCellRange.RowFrom property 53 XLPrintSettings.CenterHorizontal property 82
XLCellRange.RowTo property 53 XLPrintSettings.CenterVertical property 82
XLCellRange.XLCellRange constructor 50 XLPrintSettings.Copies property 82
XLCellRangeCollection class 55 XLPrintSettings.DraftQuality property 82
about XLCellRangeCollection class 55 XLPrintSettings.FitPagesAcross property 83
all members 55 XLPrintSettings.FitPagesDown property 83
methods 57 XLPrintSettings.Footer property 84
properties 56 XLPrintSettings.Header property 84
XLCellRangeCollection.Add method 57 XLPrintSettings.Landscape property 85
XLCellRangeCollection.Clear method 59 XLPrintSettings.MarginBottom property 85
XLCellRangeCollection.Contains method 60 XLPrintSettings.MarginFooter property 86
XLCellRangeCollection.Count property 56 XLPrintSettings.MarginHeader property 86
XLCellRangeCollection.IndexOf method 60 XLPrintSettings.MarginLeft property 86
146 · Index

XLPrintSettings.MarginRight property 87 XLSheetCollection class 112


XLPrintSettings.MarginTop property 87 about XLSheetCollection class 112
XLPrintSettings.PaperKind property 87 all members 112
XLPrintSettings.PrintGridlines property 87 methods 116
XLPrintSettings.PrintHeaders property 88 properties 113
XLPrintSettings.PrintPagesInRows property 88 XLSheetCollection.Add method 116
XLPrintSettings.ScalingFactor property 88 XLSheetCollection.Book property 113
XLPrintSettings.StartPage property 89 XLSheetCollection.Clear method 118
XLPrintSettings.XLPrintSettings constructor 79 XLSheetCollection.Contains method 118
XLRow class 90 XLSheetCollection.Count property 114
about XLRow class 89 XLSheetCollection.IndexOf method 120
all members 90 XLSheetCollection.Insert method 121
constructor 90 XLSheetCollection.Item property 114
properties 90 XLSheetCollection.Remove method 123
XLRow.Book property 91 XLSheetCollection.RemoveAt method 124
XLRow.Height property 91 XLSheetCollection.SelectedIndex property 115
XLRow.Sheet property 91 XLStyle class 125
XLRow.Style property 92 about XLStyle class 125
XLRow.Visible property 92 all members 125
XLRow.XLRow constructor 90 constructor 126
XLRowCollection class 93 methods 136
about XLRowCollection class 92 properties 127
all members 93 XLStyle.AlignHorz property 128
methods 96 XLStyle.AlignVert property 128
properties 94 XLStyle.BackColor property 129
XLRowCollection.Add method 96 XLStyle.BackPattern property 129
XLRowCollection.Book property 94 XLStyle.BorderBottom property 129
XLRowCollection.Clear method 98 XLStyle.BorderColorBottom property 130
XLRowCollection.Contains method 98 XLStyle.BorderColorLeft property 130
XLRowCollection.Count property 94 XLStyle.BorderColorRight property 131
XLRowCollection.Frozen property 95 XLStyle.BorderColorTop property 131
XLRowCollection.IndexOf method 98 XLStyle.BorderLeft property 131
XLRowCollection.Insert method 99 XLStyle.BorderRight property 132
XLRowCollection.Item property 95 XLStyle.BorderTop property 132
XLRowCollection.Remove method 101 XLStyle.Clone method 137
XLRowCollection.RemoveAt method 101 XLStyle.Diagonal property 132
XLRowCollection.Sheet property 96 XLStyle.DiagonalColor property 133
XLS Files 21 XLStyle.DiagonalStyle property 133
XLSheet class 103 XLStyle.Equals method 137
about XLSheet class 102 XLStyle.Font property 133
all members 103 XLStyle.ForeColor property 134
methods 110 XLStyle.Format property 134
properties 103 XLStyle.FormatDotNetToXL method 138
XLSheet.Book property 104 XLStyle.FormatXLToDotNet method 139
XLSheet.Clone method 110 XLStyle.GetHashCode method 140
XLSheet.Columns property 104 XLStyle.Locked property 135
XLSheet.DefaultColumnWidth property 105 XLStyle.PatternColor property 135
XLSheet.DefaultRowHeight property 105 XLStyle.Rotation property 135
XLSheet.GetCell method 111 XLStyle.SetBorderColor method 140
XLSheet.Locked property 106 XLStyle.SetBorderStyle method 141
XLSheet.MergedCells property 107 XLStyle.WordWrap property 136
XLSheet.Name property 108 XLStyle.XLStyle constructor 126
XLSheet.PrintSettings property 108
XLSheet.Rows property 109
XLSheet.ShowGridLines property 109
XLSheet.Visible property 109

Vous aimerez peut-être aussi