[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Workbook.GetNames

GetNames Method

GetNames(string)

Gets all sheet names and tables names that will be used as the parameter source of ImportData.
If the name is a table name, the worksheet name is qualified before the table name, such as "Sheet1!Table1".

Declaration
public static string[] GetNames(string fileName)
Public Shared Function GetNames(fileName As String) As String()
Parameters
Type Name Description
string fileName

The path and name for the file.

Returns
Type Description
string[]

An array of possible import names.

Examples
Workbook sourceWorkbook = new Workbook();
IWorksheet sheet = sourceWorkbook.Worksheets[0];
sheet.Range["A1:B2"].Value = new object[,] { { "Item", "Value" }, { "Sales", 100 } };
ITable table = sheet.Tables.Add(sheet.Range["A1:B2"], true);
table.Name = "SalesTable";
string fileName = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), ".xlsx"));
sourceWorkbook.Save(fileName);
string[] names = Workbook.GetNames(fileName);

GetNames(Stream)

Gets all sheet names and tables names that will be used as the parameter source of ImportData.
If the name is a table name, the worksheet name is qualified before the table name, such as "Sheet1!Table1".

Declaration
public static string[] GetNames(Stream fileStream)
Public Shared Function GetNames(fileStream As Stream) As String()
Parameters
Type Name Description
Stream fileStream

The fileStream of a workbook.

Returns
Type Description
string[]

An array of possible import names.

Examples
Workbook sourceWorkbook = new Workbook();
IWorksheet sheet = sourceWorkbook.Worksheets[0];
sheet.Range["A1:B2"].Value = new object[,] { { "Item", "Value" }, { "Sales", 100 } };
ITable table = sheet.Tables.Add(sheet.Range["A1:B2"], true);
table.Name = "SalesTable";
using (MemoryStream stream = new MemoryStream())
{
    sourceWorkbook.Save(stream);
    stream.Position = 0;
    string[] names = Workbook.GetNames(stream);
}