ExcelFile.Open Method
Overloads
- ExcelFile.Open(String)
- ExcelFile.Open(Stream)
- ExcelFile.Open(String, TFileFormats, Char, Int32, Int32, ColumnImportType[])
- ExcelFile.Open(Stream, TFileFormats, Char, Int32, Int32, ColumnImportType[])
- ExcelFile.Open(Stream, TFileFormats, Char, Int32, Int32, ColumnImportType[], Boolean)
- ExcelFile.Open(String, TFileFormats, Char, Int32, Int32, ColumnImportType[], Encoding, Boolean)
- ExcelFile.Open(Stream, TFileFormats, Char, Int32, Int32, ColumnImportType[], Encoding, Boolean)
- ExcelFile.Open(String, TFileFormats, Char, Int32, Int32, ColumnImportType[], String[], Encoding, Boolean)
- ExcelFile.Open(Stream, TFileFormats, Char, Int32, Int32, ColumnImportType[], String[], Encoding, Boolean)
ExcelFile.Open(String)
Loads a new Spreadsheet from disk.
Syntax
Namespace: FlexCel.Core
public void Open(String fileName)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
fileName | String | File to open. |
See also
ExcelFile.Open(Stream)
Loads a new Spreadsheet from a stream.
Syntax
Namespace: FlexCel.Core
public void Open(Stream aStream)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
aStream | Stream | Stream to Load, must be a seekable stream. Verify it is on the correct position. |
See also
ExcelFile.Open(String, TFileFormats, Char, Int32, Int32, ColumnImportType[])
Loads a new Spreadsheet from disk, on one of the specified formats.
Syntax
Namespace: FlexCel.Core
public void Open(String fileName, TFileFormats fileFormat, Char delimiter, Int32 firstRow, Int32 firstCol, ColumnImportType[] columnFormats)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
fileName | String | File to open | |
fileFormat | TFileFormats | List with possible file formats to try | |
delimiter | Char | Delimiter used to separate columns, if the format is TFileFormats.Text | |
firstRow | Int32 | First row where we will copy the cells on the new sheet, for TFileFormats.Text | |
firstCol | Int32 | First column where we will copy the cells on the new sheet, for TFileFormats.Text | |
columnFormats | ColumnImportType[] | An array of ColumnImportType elements, telling how each column should be imported. |
See also
ExcelFile.Open(Stream, TFileFormats, Char, Int32, Int32, ColumnImportType[])
Loads a new Spreadsheet from a stream, on one of the specified formats.
Syntax
Namespace: FlexCel.Core
public void Open(Stream aStream, TFileFormats fileFormat, Char delimiter, Int32 firstRow, Int32 firstCol, ColumnImportType[] columnFormats)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
aStream | Stream | Stream to open, must be a seekable stream. Verify it is on the correct position. | |
fileFormat | TFileFormats | List with possible file formats to try. | |
delimiter | Char | Delimiter used to separate columns, if the format is TFileFormats.Text | |
firstRow | Int32 | First row where we will copy the cells on the new sheet, for TFileFormats.Text | |
firstCol | Int32 | First column where we will copy the cells on the new sheet, for TFileFormats.Text | |
columnFormats | ColumnImportType[] | An array of ColumnImportType elements, telling how each column should be imported. See the example for more information on how to use it. |
Examples
Imagine you have a file with 20 columns, and column 2 has numbers you want to be imported as text (like phone numbers), and you don't want to import column 10.
You can use the following code to do it:
ColumnImportType[] ColTypes = new ColumnImportType[10]; //You just need to define 10 items, all other columns after 10 will be imported with default formatting.
ColTypes[1] = ColumnImportType.Text; //Import whatever is in column 2 as text.
ColTypes[9] = ColumnImportType.Skip; //don't import column 10.
ExcelFile xls = new XlsFile(true); //Create a new file.
xls.Open("csv.csv", TFileFormats.Text, ',', 1, 1, ColTypes); //Import the csv text.
See also
ExcelFile.Open(Stream, TFileFormats, Char, Int32, Int32, ColumnImportType[], Boolean)
Loads a new Spreadsheet from a stream, on one of the specified formats.
Syntax
Namespace: FlexCel.Core
public void Open(Stream aStream, TFileFormats fileFormat, Char delimiter, Int32 firstRow, Int32 firstCol, ColumnImportType[] columnFormats, Boolean detectEncodingFromByteOrderMarks)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
aStream | Stream | Stream to open, must be a seekable stream. Verify it is on the correct position. | |
fileFormat | TFileFormats | List with possible file formats to try. | |
delimiter | Char | Delimiter used to separate columns, if the format is TFileFormats.Text | |
firstRow | Int32 | First row where we will copy the cells on the new sheet, for TFileFormats.Text | |
firstCol | Int32 | First column where we will copy the cells on the new sheet, for TFileFormats.Text | |
columnFormats | ColumnImportType[] | An array of ColumnImportType elements, telling how each column should be imported. See the example for more information on how to use it. |
|
detectEncodingFromByteOrderMarks | Boolean | This parameter only applies when reading Text files. It is the same on the constructor of a StreamReader, and it says if BOM must be used at the beginning of the file. It defaults to true. |
Examples
Imagine you have a file with 20 columns, and column 2 has numbers you want to be imported as text (like phone numbers), and you don't want to import column 10.
You can use the following code to do it:
ColumnImportType[] ColTypes = new ColumnImportType[10]; //You just need to define 10 items, all other columns after 10 will be imported with default formatting.
ColTypes[1] = ColumnImportType.Text; //Import whatever is in column 2 as text.
ColTypes[9] = ColumnImportType.Skip; //don't import column 10.
ExcelFile xls = new XlsFile(true); //Create a new file.
xls.Open("csv.csv", TFileFormats.Text, ',', 1, 1, ColTypes); //Import the csv text.
See also
ExcelFile.Open(String, TFileFormats, Char, Int32, Int32, ColumnImportType[], Encoding, Boolean)
Loads a new Spreadsheet from disk, on one of the specified formats.
Syntax
Namespace: FlexCel.Core
public void Open(String fileName, TFileFormats fileFormat, Char delimiter, Int32 firstRow, Int32 firstCol, ColumnImportType[] columnFormats, Encoding fileEncoding, Boolean detectEncodingFromByteOrderMarks)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
fileName | String | File to open | |
fileFormat | TFileFormats | List with possible file formats to try | |
delimiter | Char | Delimiter used to separate columns, if the format is TFileFormats.Text | |
firstRow | Int32 | First row where we will copy the cells on the new sheet, for TFileFormats.Text | |
firstCol | Int32 | First column where we will copy the cells on the new sheet, for TFileFormats.Text | |
columnFormats | ColumnImportType[] | An array of ColumnImportType elements, telling how each column should be imported. | |
fileEncoding | Encoding | Encoding used by the file we are reading, when opening a Text-delimited file (csv or txt). If you specify an encoding for xls95 files, it will overwrite the default encoding specified in the file, and this can be used to read buggy or corrupted xls95 files. But in general for xls95 you should keep this parameter null. This parameter has no effect on xls 97 files or xlsx. If null when reading text files, it is assumed to be Encoding.UTF8. |
|
detectEncodingFromByteOrderMarks | Boolean | This parameter only applies when reading Text files. It is the same on the constructor of a StreamReader, and it says if BOM must be used at the beginning of the file. It defaults to true. |
See also
ExcelFile.Open(Stream, TFileFormats, Char, Int32, Int32, ColumnImportType[], Encoding, Boolean)
Loads a new Spreadsheet from a stream, on one of the specified formats.
Syntax
Namespace: FlexCel.Core
public void Open(Stream aStream, TFileFormats fileFormat, Char delimiter, Int32 firstRow, Int32 firstCol, ColumnImportType[] columnFormats, Encoding fileEncoding, Boolean detectEncodingFromByteOrderMarks)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
aStream | Stream | Stream to open, must be a seekable stream. Verify it is on the correct position. | |
fileFormat | TFileFormats | List with possible file formats to try. | |
delimiter | Char | Delimiter used to separate columns, if the format is TFileFormats.Text | |
firstRow | Int32 | First row where we will copy the cells on the new sheet, for TFileFormats.Text | |
firstCol | Int32 | First column where we will copy the cells on the new sheet, for TFileFormats.Text | |
columnFormats | ColumnImportType[] | An array of ColumnImportType elements, telling how each column should be imported. See the example for more information on how to use it. |
|
fileEncoding | Encoding | Encoding used by the file we are reading, when opening a Text-delimited file (csv or txt). If you specify an encoding for xls95 files, it will overwrite the default encoding specified in the file, and this can be used to read buggy or corrupted xls95 files. But in general for xls95 you should keep this parameter null. This parameter has no effect on xls 97 files or xlsx. If null when reading text files, it is assumed to be Encoding.UTF8. |
|
detectEncodingFromByteOrderMarks | Boolean | This parameter only applies when reading Text files. It is the same on the constructor of a StreamReader, and it says if BOM must be used at the beginning of the file. It defaults to true. |
Examples
Imagine you have a file with 20 columns, and column 2 has numbers you want to be imported as text (like phone numbers), and you don't want to import column 10.
You can use the following code to do it:
ColumnImportType[] ColTypes = new ColumnImportType[10]; //You just need to define 10 items, all other columns after 10 will be imported with default formatting.
ColTypes[1] = ColumnImportType.Text; //Import whatever is in column 2 as text.
ColTypes[9] = ColumnImportType.Skip; //don't import column 10.
ExcelFile xls = new XlsFile(true); //Create a new file.
xls.Open("csv.csv", TFileFormats.Text, ',', 1, 1, ColTypes); //Import the csv text.
See also
ExcelFile.Open(String, TFileFormats, Char, Int32, Int32, ColumnImportType[], String[], Encoding, Boolean)
Loads a new Spreadsheet from disk, on one of the specified formats.
Syntax
Namespace: FlexCel.Core
public abstract void Open(String fileName, TFileFormats fileFormat, Char delimiter, Int32 firstRow, Int32 firstCol, ColumnImportType[] columnFormats, String[] dateFormats, Encoding fileEncoding, Boolean detectEncodingFromByteOrderMarks)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
fileName | String | File to open | |
fileFormat | TFileFormats | List with possible file formats to try | |
delimiter | Char | Delimiter used to separate columns, if the format is TFileFormats.Text | |
firstRow | Int32 | First row where we will copy the cells on the new sheet, for TFileFormats.Text | |
firstCol | Int32 | First column where we will copy the cells on the new sheet, for TFileFormats.Text | |
columnFormats | ColumnImportType[] | An array of ColumnImportType elements, telling how each column should be imported. | |
dateFormats | String[] | A list of formats allowed for dates and times, when opening text files. Windows is a little liberal in what it thinks can be a date, and it can convert things like "1.2" into dates. By setting this property, you can ensure the dates are only in the formats you expect. If you leave it null, we will trust "DateTime.TryParse" to guess the correct values. This value has no meaning in normal xls files, only text files. | |
fileEncoding | Encoding | Encoding used by the file we are reading, when opening a Text-delimited file (csv or txt). If you specify an encoding for xls95 files, it will overwrite the default encoding specified in the file, and this can be used to read buggy or corrupted xls95 files. But in general for xls95 you should keep this parameter null. This parameter has no effect on xls 97 files or xlsx. If null when reading text files, it is assumed to be Encoding.UTF8. |
|
detectEncodingFromByteOrderMarks | Boolean | This parameter only applies when reading Text files. It is the same on the constructor of a StreamReader, and it says if BOM must be used at the beginning of the file. It defaults to true. |
See also
ExcelFile.Open(Stream, TFileFormats, Char, Int32, Int32, ColumnImportType[], String[], Encoding, Boolean)
Loads a new Spreadsheet from a stream, on one of the specified formats.
Syntax
Namespace: FlexCel.Core
public abstract void Open(Stream aStream, TFileFormats fileFormat, Char delimiter, Int32 firstRow, Int32 firstCol, ColumnImportType[] columnFormats, String[] dateFormats, Encoding fileEncoding, Boolean detectEncodingFromByteOrderMarks)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
aStream | Stream | Stream to open, must be a seekable stream. Verify it is on the correct position. | |
fileFormat | TFileFormats | List with possible file formats to try. | |
delimiter | Char | Delimiter used to separate columns, if the format is TFileFormats.Text | |
firstRow | Int32 | First row where we will copy the cells on the new sheet, for TFileFormats.Text | |
firstCol | Int32 | First column where we will copy the cells on the new sheet, for TFileFormats.Text | |
columnFormats | ColumnImportType[] | An array of ColumnImportType elements, telling how each column should be imported. See the example for more information on how to use it. |
|
dateFormats | String[] | A list of formats allowed for dates and times, when opening text files. Windows is a little liberal in what it thinks can be a date, and it can convert things like "1.2" into dates. By setting this property, you can ensure the dates are only in the formats you expect. If you leave it null, we will trust "DateTime.TryParse" to guess the correct values. This value has no meaning in normal xls files, only text files. | |
fileEncoding | Encoding | Encoding used by the file we are reading, when opening a Text-delimited file (csv or txt). If you specify an encoding for xls95 files, it will overwrite the default encoding specified in the file, and this can be used to read buggy or corrupted xls95 files. But in general for xls95 you should keep this parameter null. This parameter has no effect on xls 97 files or xlsx. If null when reading text files, it is assumed to be Encoding.UTF8. |
|
detectEncodingFromByteOrderMarks | Boolean | This parameter only applies when reading Text files. It is the same on the constructor of a StreamReader, and it says if BOM must be used at the beginning of the file. It defaults to true. |
Examples
Imagine you have a file with 20 columns, and column 2 has numbers you want to be imported as text (like phone numbers), and you don't want to import column 10.
You can use the following code to do it:
ColumnImportType[] ColTypes = new ColumnImportType[10]; //You just need to define 10 items, all other columns after 10 will be imported with default formatting.
ColTypes[1] = ColumnImportType.Text; //Import whatever is in column 2 as text.
ColTypes[9] = ColumnImportType.Skip; //don't import column 10.
ExcelFile xls = new XlsFile(true); //Create a new file.
xls.Open("csv.csv", TFileFormats.Text, ',', 1, 1, ColTypes); //Import the csv text.