Free Support Forum - aspose.com

Display all fields from table using smart markers

is there a way to display values from all columns/fields in Excel using smart markers without socifying each field name.

ex:

instead of doing this for each field

&=TblCustomers.FirstName in column A

&=TblCustomers.LastName in column B

&=TblCustomers.CustomerID in column C

is there a way have all columns of a table display?

Hi,

Thanks for your posting and using Aspose.Cells.

We are afraid, this is not possible. However as a workaround you can import your datatable along with data and column names into worksheet directly using Aspose.Cells ImportDataTable() method.

Please see the following documentation article and check the section Importing from DataTable for your reference.

( http://www.aspose.com/docs/display/cellsnet/Importing+Data+to+Worksheets )

hi,

I'll review the information from the link you sent , so yes i can bring a whole table in to excel but I didnt see an option where i can specify a specific cell where the data from the datatable will start. Is there an option to do that, lets say, i want my data from table to begin in cell E15?

Hi,

Thanks for your posting and using Aspose.Cells.

Do you want to place your data table starting from cell E15. It is possible using this statement.

worksheet.Cells.ImportDataTable(dataTable, true, “E15”);

Please see the full run able sample code and its output excel file which I have attached on this thread for your reference.

C#
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

//Instantiating a “Products” DataTable object
DataTable dataTable = new DataTable(“Products”);

//Adding columns to the DataTable object
dataTable.Columns.Add(“Product ID”, typeof(Int32));
dataTable.Columns.Add(“Product Name”, typeof(string));
dataTable.Columns.Add(“Units In Stock”, typeof(Int32));

//Creating an empty row in the DataTable object
DataRow dr = dataTable.NewRow();

//Adding data to the row
dr[0] = 1;
dr[1] = “Aniseed Syrup”;
dr[2] = 15;

//Adding filled row to the DataTable object
dataTable.Rows.Add(dr);

//Creating another empty row in the DataTable object
dr = dataTable.NewRow();

//Adding data to the row
dr[0] = 2;
dr[1] = “Boston Crab Meat”;
dr[2] = 123;

//Adding filled row to the DataTable object
dataTable.Rows.Add(dr);

//Importing the contents of DataTable to the worksheet starting from “E15” cell,
//where true specifies that the column names of the DataTable would be added to
//the worksheet as a header row
worksheet.Cells.ImportDataTable(dataTable, true, “E15”);

workbook.Save(“output.xlsx”);