Interface IApplication
Represents the Excel application.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.Portable.dll
Syntax
public interface IApplication : IParentApplication
Properties
ActiveCell
Returns a Range object that represents the active cell in the active window (the window on top) or in the specified window. If the window isn't displaying a worksheet, this property fails. Read-only.
Declaration
IRange ActiveCell { get; }
Property Value
Type |
---|
IRange |
ActiveSheet
Returns an object that represents the active sheet (the sheet on top) in the active workbook or in the specified window or workbook. Returns Nothing if no sheet is active. Read-only.
Declaration
IWorksheet ActiveSheet { get; }
Property Value
Type |
---|
IWorksheet |
ActiveWorkbook
Returns a Workbook object that represents the workbook in the active window (the window on top). Read-only. Returns Nothing if there are no windows open or if either the Info window or the Clipboard window is the active window.
Declaration
IWorkbook ActiveWorkbook { get; }
Property Value
Type |
---|
IWorkbook |
ArgumentsSeparator
Formula arguments separator.
Declaration
char ArgumentsSeparator { get; set; }
Property Value
Type |
---|
System.Char |
Build
Returns the Microsoft Excel build number. Read-only.
Declaration
int Build { get; }
Property Value
Type |
---|
System.Int32 |
ChangeStyleOnCellEdit
If this property is set to True, then if some cells have reference to the same style, changes will influence all these cells. Default value: False
Declaration
bool ChangeStyleOnCellEdit { get; set; }
Property Value
Type |
---|
System.Boolean |
CompressionLevel
Compression level for workbooks serialization.
Declaration
Nullable<CompressionLevel> CompressionLevel { get; set; }
Property Value
Type |
---|
System.Nullable<CompressionLevel> |
CsvQualifier
Gets or sets the qualifier to put around the results with separator or record delimiter.
Declaration
string CsvQualifier { get; set; }
Property Value
Type |
---|
System.String |
Remarks
In the above example, the CSV qualifier is set as "$" and the separator is (,). So, the G1 cell value "qualifier,text" will be surrounded by qualifier because it contains the separator while saving workbook as CSV document.
Output of the above code looks like this. This,is,a,sample,to,set,$qualifier,text$
If the results contain the qualifier, the qualifier is repeated. The Qualifier setting must be different from the Separator and RecordDelimiter settings. The default value is quotation (").
Examples
using(ExcelEngine engine = new ExcelEngine())
{
IApplication application = engine.Excel;
application.CsvQualifier ="$";
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
worksheet["A1"].Text = "This";
worksheet["B1"].Text = "is";
worksheet["C1"].Text = "a";
worksheet["D1"].Text = "sample";
worksheet["E1"].Text = "to";
worksheet["F1"].Text = "set";
worksheet["G1"].Text = "qualifier,text";
MemoryStream stream = new MemoryStream();
workbook.SaveAs(stream, ",", Encoding.Unicode);
}
CsvRecordDelimiter
Gets or sets the record delimiter to put at the end of each record.
Declaration
string CsvRecordDelimiter { get; set; }
Property Value
Type |
---|
System.String |
Remarks
In the above example, CSV record delimiter is set as '$'. It will be added at the end of each row while saving workbook as CSV document.
Output of the above code looks like this. This,is,a,sample$ to,set,Record Delimiter$
The default value is Carriage Return(CR) and Line Feed(LF).
Examples
using(ExcelEngine engine = new ExcelEngine())
{
IApplication application = engine.Excel;
application.CsvRecordDelimiter ="$";
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
worksheet["A1"].Text = "This";
worksheet["B1"].Text = "is";
worksheet["C1"].Text = "a";
worksheet["D1"].Text = "sample";
worksheet["A2"].Text = "to";
worksheet["B2"].Text = "set";
worksheet["C2"].Text = "Record Delimiter";
MemoryStream stream = new MemoryStream();
workbook.SaveAs(stream, ",", Encoding.Unicode);
}
CSVSeparator
Represents CSV Separator. Using for Auto recognize file type.
Declaration
string CSVSeparator { get; set; }
Property Value
Type |
---|
System.String |
DataProviderType
Changes data provider type for all operations after it.
Declaration
ExcelDataProviderType DataProviderType { get; set; }
Property Value
Type |
---|
ExcelDataProviderType |
DecimalSeparator
Sets or returns the character used for the decimal separator as a String. Read/write.
Declaration
string DecimalSeparator { get; set; }
Property Value
Type |
---|
System.String |
DefaultVersion
Gets / sets default excel version. This value is used in create methods.
Declaration
ExcelVersion DefaultVersion { get; set; }
Property Value
Type |
---|
ExcelVersion |
DeleteDestinationFile
Indicates whether XlsIO should delete destination file before saving into it. Default value is TRUE.
Declaration
bool DeleteDestinationFile { get; set; }
Property Value
Type |
---|
System.Boolean |
EnableIncrementalFormula
Specifies whether to increment the references in formula automatically. Default value is false.
Declaration
bool EnableIncrementalFormula { get; set; }
Property Value
Type |
---|
System.Boolean |
EnablePartialTrustCode
Specifies whether to run Partial trust code.
Declaration
bool EnablePartialTrustCode { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
True if to run partial trust code; otherwise, false.
ExcludeAdditionalCharacters
Flag to ignore exception and exclude characters more than 32767 (maximum allowed characters) in a cell text.
Declaration
bool ExcludeAdditionalCharacters { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
using(ExcelEngine engine = new ExcelEngine())
{
//Instantiate the application object
IApplication application = engine.Excel;
//Set flag to ignore exception and exclude additional characters
application.ExcludeAdditionalCharacters = true;
//Open the existing workbook
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
//Access the first worksheet
IWorksheet worksheet = workbook.Worksheets[0];
//Save the workbook
workbook.SaveAs("Output.xlsx");
}
FallbackFonts
Declaration
FallbackFonts FallbackFonts { get; }
Property Value
Type |
---|
FallbackFonts |
FixedDecimal
All data entered after this property is set to True will be formatted with the number of fixed decimal places set by the FixedDecimalPlaces property. Read/write Boolean.
Declaration
bool FixedDecimal { get; set; }
Property Value
Type |
---|
System.Boolean |
FixedDecimalPlaces
Returns or sets the number of fixed decimal places used when the FixedDecimal property is set to True. Read/write.
Declaration
int FixedDecimalPlaces { get; set; }
Property Value
Type |
---|
System.Int32 |
IgnoreSheetNameException
Gets or sets a Boolean value to ignore duplicate worksheet name exception by adding a suffix at the end.Default value is FALSE.
Declaration
bool IgnoreSheetNameException { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
using(ExcelEngine engine = new ExcelEngine())
{
IApplication application = engine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(3);
application.IgnoreSheetNameException = true;
IWorksheet sheet_1 = workbook.Worksheets[0];
IWorksheet sheet_2 = workbook.Worksheets[1];
IWorksheet sheet_3 = workbook.Worksheets[2];
Console.WriteLine("First sheet name is " + sheet_1.Name);
Console.WriteLine("Second sheet name is " + sheet_2.Name);
Console.WriteLine("Third sheet name is " + sheet_3.Name);
Console.WriteLine("Set sheet1 to Thired sheet name");
sheet_3.Name = "Sheet1";
Console.WriteLine("After set the third sheet name is " + sheet_3.Name);
workbook.SaveAs("Output.xlsx");
workbook.Close();
}
Output :
First sheet name is Sheet1 Second sheet name is Sheet2 Third sheet name is Sheet3
Set sheet1 to Thired sheet name
After set the third sheet name is Sheet1_1
IsChartCacheEnabled
Gets or sets a boolean value which indicates whether the chart caches are enabled or not Default value is false.
Declaration
bool IsChartCacheEnabled { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
If set "true" XlsIO will give parsing and serializing support for chart caches which lead some performance delay and memory consumption
Some spreadsheet viewer requires chart caches to view the chart
This property is supported on Windows Forms, WPF, ASP.NET, ASP.NET MVC, WinRT, WP, Universal and UWP platforms only.MaximumColumnsForCsv
Get or set maximum columns for CSV file.
Declaration
int MaximumColumnsForCsv { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Instantiate the application object
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
//Set the maximum columns for CSV file
application.MaximumColumnsForCSV = 25000;
//Open the existing workbook
IWorkbook workbook = application.Workbooks.Open("Sample.csv");
//Access the first worksheet
IWorksheet sheet = workbook.Worksheets[0];
//Save the workbook
workbook.SaveAs("Output.csv",",");
}
MaximumRowsForCsv
Get or set maximum rows for CSV file.
Declaration
int MaximumRowsForCsv { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Instantiate the application object
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
//Set the maximum rows for CSV file
application.MaximumRowsForCSV = 3000000;
//Open the existing workbook
IWorkbook workbook = application.Workbooks.Open("Sample.csv");
//Access the first worksheet
IWorksheet sheet = workbook.Worksheets[0];
//Save the workbook
workbook.SaveAs("Output.csv",",");
}
OptimizeFonts
Indicates whether to optimize fonts count. This option will take effect only on workbooks that will be added after setting this property. WARNING: Setting this property to True can decrease performance significantly, but will reduce resulting file size.
Declaration
bool OptimizeFonts { get; set; }
Property Value
Type |
---|
System.Boolean |
OptimizeImport
Indicates whether to optimize Import data. This option will take effect only on Import methods that are available with the worksheet WARNING: Setting this property to True can decrease memory significantly, but will increase the performance of data import .
Declaration
bool OptimizeImport { get; set; }
Property Value
Type |
---|
System.Boolean |
PreserveCSVDataTypes
Indicates whether to preserve the datatypes for the CSV file formats.
Declaration
bool PreserveCSVDataTypes { get; set; }
Property Value
Type |
---|
System.Boolean |
Range
Returns a Range object that represents a cell or a range of cells.
Declaration
IRange Range { get; }
Property Value
Type |
---|
IRange |
RangeIndexerMode
Specifies whether the range should be accessed from worksheet or within the range object scope..
Declaration
ExcelRangeIndexerMode RangeIndexerMode { get; set; }
Property Value
Type |
---|
ExcelRangeIndexerMode |
RowSeparator
Gets / sets row separator for array parsing.
Declaration
char RowSeparator { get; set; }
Property Value
Type |
---|
System.Char |
RowStorageAllocationBlockSize
Gets / sets memory allocation block for single row. Each row will allocate memory block that can be divided on this number. Smaller value means smaller memory usage but slower speed when changing cell's value. Default value is 128. That is enough to allocate 9 string records, or 9 integer numbers (or floating numbers with 1 or 2 digits after decimal point) or 7 double numbers.
Declaration
int RowStorageAllocationBlockSize { get; set; }
Property Value
Type |
---|
System.Int32 |
SheetsInNewWorkbook
Returns or sets the number of sheets that Microsoft Excel automatically inserts into new workbooks. Read/write Long.
Declaration
int SheetsInNewWorkbook { get; set; }
Property Value
Type |
---|
System.Int32 |
SkipAutoFitRow
Gets or sets a Boolean value to skip the call of AutofitRow(Int32) method while accessing row height. Default value is FALSE.
Declaration
bool SkipAutoFitRow { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
using(ExcelEngine engine = new ExcelEngine())
{
IApplication application = engine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
//skip autofit row property is set to true.
application.SkipAutoFitRow = true;
double rowHeight = worksheet.GetRowHeight(1);
Console.WriteLine("SkipAutoFitRow set to true , result will be");
Console.WriteLine(rowHeight);
//skip autofit row property is set to false.
application.SkipAutoFitRow = false;
double afterRowHeight = worksheet.GetRowHeight(1);
Console.WriteLine("SkipAutoFitRow set to false , result will be");
Console.WriteLine(afterRowHeight);
workbook.SaveAs("output.xlsx");
}
Output :
SkipAutoFitRow set to true , result will be 40.5 SkipAutoFitRow set to false , result will be 36.35
SkipOnSave
This flag controls behavior of workbook save methods. Each flag controls one aspect of the save code. Can be set one or more flags which will influence the output produced by the library.
Declaration
SkipExtRecords SkipOnSave { get; set; }
Property Value
Type |
---|
SkipExtRecords |
StandardFont
Returns or sets the name of the standard font. Read/write String.
Declaration
string StandardFont { get; set; }
Property Value
Type |
---|
System.String |
StandardFontSize
Returns or sets the standard font size, in points. Read/write.
Declaration
double StandardFontSize { get; set; }
Property Value
Type |
---|
System.Double |
StandardHeight
Returns or sets the standard (default) height of all the rows in the worksheet, in points. This value is used only for newly created worksheets. Read/write Double.
Declaration
double StandardHeight { get; set; }
Property Value
Type |
---|
System.Double |
StandardHeightFlag
Returns or sets the standard (default) height option flag, which defines that standard (default) row height and book default font height do not match. This value is used only for newly created worksheets. Read/write Bool.
Declaration
bool StandardHeightFlag { get; set; }
Property Value
Type |
---|
System.Boolean |
StandardWidth
Returns or sets the standard (default) width of all the columns in the worksheet. This value is used only for newly created worksheets. Read/write Double.
Declaration
double StandardWidth { get; set; }
Property Value
Type |
---|
System.Double |
ThousandsSeparator
Sets or returns the character used for the thousands separator as a String. Read / write.
Declaration
string ThousandsSeparator { get; set; }
Property Value
Type |
---|
System.String |
UpdateSheetFormulaReference
Specifies whether to remove worksheet reference in formulas on removing and reattaching the worksheet. Default value is TRUE.
Declaration
bool UpdateSheetFormulaReference { get; set; }
Property Value
Type |
---|
System.Boolean |
UseFastRecordParsing
Indicates whether to try fast record parsing.
Declaration
bool UseFastRecordParsing { get; set; }
Property Value
Type |
---|
System.Boolean |
UseNativeOptimization
Indicates is use unsafe code.
Declaration
bool UseNativeOptimization { get; set; }
Property Value
Type |
---|
System.Boolean |
UseNativeStorage
Indicates whether we should use native storage (standard windows COM object) or our .Net implementation to open excel 97-2003 files.
Declaration
bool UseNativeStorage { get; set; }
Property Value
Type |
---|
System.Boolean |
UserName
Returns or sets the name of the current user. Read/write String.
Declaration
string UserName { get; set; }
Property Value
Type |
---|
System.String |
UseStringDelimiter
Gets or sets a boolean value indicating whether to add string delimiter for all the text values. Default value is FALSE.
Declaration
bool UseStringDelimiter { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
In the above example, cell A1 contains a text value. So, it will be surrounded by string delimiter i.e., double quotes while saving workbook as CSV document.
Output of the above code looks like this. "Document",6
Examples
using(ExcelEngine engine = new ExcelEngine())
{
IApplication application = engine.Excel;
application.UseStringDelimiter = true;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
worksheet["A1"].Text = "Document";
worksheet["B1"].Value = "6";
MemoryStream stream = new MemoryStream();
workbook.SaveAs(stream, ",",Encoding.Unicode);
}
UseSystemSeparators
True (default) if the system separators of Microsoft Excel are enabled. Read/write Boolean.
Declaration
bool UseSystemSeparators { get; set; }
Property Value
Type |
---|
System.Boolean |
Value
For the Application object, always returns "Microsoft Excel". For the CubeField object, the name of the specified field. For the Style object, the name of the specified style. Read-only String.
Declaration
string Value { get; }
Property Value
Type |
---|
System.String |
Workbooks
Returns a Workbooks collection that represents all the open workbooks. Read-only.
Declaration
IWorkbooks Workbooks { get; }
Property Value
Type |
---|
IWorkbooks |
Worksheets
For an Application object, returns a Sheets collection that represents all the worksheets in the active workbook. For a Workbook object, returns a Sheets collection that represents all the worksheets in the specified workbook. Read-only Sheets object.
Declaration
IWorksheets Worksheets { get; }
Property Value
Type |
---|
IWorksheets |
XlsIORenderer
Represents the Worksheet to image converter instance for NetStandard.
Declaration
IXlsIORenderer XlsIORenderer { get; set; }
Property Value
Type |
---|
IXlsIORenderer |
Remarks
This property is supported in NetStandard supported platforms only.
Methods
add_OnPasswordRequired(PasswordRequiredEventHandler)
Declaration
void add_OnPasswordRequired(PasswordRequiredEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PasswordRequiredEventHandler | value |
add_OnWrongPassword(PasswordRequiredEventHandler)
Declaration
void add_OnWrongPassword(PasswordRequiredEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PasswordRequiredEventHandler | value |
add_ProgressEvent(ProgressEventHandler)
Declaration
void add_ProgressEvent(ProgressEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ProgressEventHandler | value |
add_SubstituteFont(SubstituteFontEventHandler)
Declaration
void add_SubstituteFont(SubstituteFontEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SubstituteFontEventHandler | value |
add_TypeMismatchOnExport(ExportEventHandler)
Declaration
void add_TypeMismatchOnExport(ExportEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ExportEventHandler | value |
CentimetersToPoints(Double)
Converts a measurement from centimeters to points (one point equals 0.035 centimeters).
Declaration
double CentimetersToPoints(double Centimeters)
Parameters
Type | Name | Description |
---|---|---|
System.Double | Centimeters | Double value in centimeters |
Returns
Type | Description |
---|---|
System.Double | Returns the converted double value in points |
ConvertUnits(Double, MeasureUnits, MeasureUnits)
Converts units.
Declaration
double ConvertUnits(double value, MeasureUnits from, MeasureUnits to)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | Value to convert. |
MeasureUnits | from | Form option. |
MeasureUnits | to | To option. |
Returns
Type | Description |
---|---|
System.Double | Returns converted result. |
InchesToPoints(Double)
Converts a measurement from inches to points.
Declaration
double InchesToPoints(double Inches)
Parameters
Type | Name | Description |
---|---|---|
System.Double | Inches | Double value in inches |
Returns
Type | Description |
---|---|
System.Double | Returns the converted double value in points |
IsExcelFile(Stream)
Checks whether a given stream contains data in Excel format.
Declaration
bool IsExcelFile(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | File stream that contains workbook. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if the file is in excel format else false. |
IsSupported(Stream)
Check whether the file version is supported by XlsIO.
Declaration
bool IsSupported(Stream Stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | Stream |
Returns
Type | Description |
---|---|
System.Boolean | Returns True if the stream is supported by XlsIO else returns False |
remove_OnPasswordRequired(PasswordRequiredEventHandler)
Declaration
void remove_OnPasswordRequired(PasswordRequiredEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PasswordRequiredEventHandler | value |
remove_OnWrongPassword(PasswordRequiredEventHandler)
Declaration
void remove_OnWrongPassword(PasswordRequiredEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PasswordRequiredEventHandler | value |
remove_ProgressEvent(ProgressEventHandler)
Declaration
void remove_ProgressEvent(ProgressEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ProgressEventHandler | value |
remove_SubstituteFont(SubstituteFontEventHandler)
Declaration
void remove_SubstituteFont(SubstituteFontEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SubstituteFontEventHandler | value |
remove_TypeMismatchOnExport(ExportEventHandler)
Declaration
void remove_TypeMismatchOnExport(ExportEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ExportEventHandler | value |
Events
OnPasswordRequired
This event is fired when user tries to open password protected workbook without specifying password. It is used to obtain password.
Declaration
event PasswordRequiredEventHandler OnPasswordRequired
Event Type
Type |
---|
PasswordRequiredEventHandler |
OnWrongPassword
This event is fired when user specified wrong password when trying to open password protected workbook. It is used to obtain correct password.
Declaration
event PasswordRequiredEventHandler OnWrongPassword
Event Type
Type |
---|
PasswordRequiredEventHandler |
ProgressEvent
When workbook is read from stream and position of the stream changed, this event is raised.
Declaration
event ProgressEventHandler ProgressEvent
Event Type
Type |
---|
ProgressEventHandler |
SubstituteFont
This event is fired to substitute an alternate font when a specified font is not installed in the production environment in Excel to PDF/Image conversion.
Declaration
event SubstituteFontEventHandler SubstituteFont
Event Type
Type |
---|
SubstituteFontEventHandler |
Remarks
This event is supported in Excel to PDF/Image conversion.
Examples
using(ExcelEngine engine = new ExcelEngine())
{
IApplication application = engine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
//Initializes the SubstituteFont event to perform font substitution during ExceltoPDFconversion.
application.SubstituteFont += new SubstituteFontEventHandler(SubstituteFont);
IWorksheet worksheet = workbook.Worksheets[0];
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
PdfDocument doc = new PdfDocument();
doc = converter.Convert();
doc.Save("PDF.pdf");
workbook.SaveAs("output.xlsx");
}
void SubstituteFont(object sender, SubstituteFontEventArgs args)
{
// Sets the alternate font when a specified font is not installed in the production environment.
if (args.OriginalFontName == "Wingdings Regular")
args.AlternateFontName = "Bauhaus 93";
else
args.AlternateFontName = "Times New Roman";
}
TypeMismatchOnExport
Declaration
event ExportEventHandler TypeMismatchOnExport
Event Type
Type |
---|
ExportEventHandler |