Automatize layout of applications

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a web application, that takes from excel a range of rows and columns...

The method that gets the data in the ranges returns an Array of two
dimensions with the data...

Then i render the data in the browser for instance using html tables....

My problem its that:

In my company we have to do a lot of applications of this type (with excel),
and i would like to automatize the resulting layout, cause i allways obtain
an array of two dimensions (sometimes biger, sometimes smaller) to render
after....

Usually im using a StringBuilder to append into the c# code the html, but i
dont like this solution cause if i have to modify the layout, i have to open
the code, recompile, and then put it on-line again...

I thought that xml maybe its a good solution. But really i dont know.

Could you give some advices about the way to do this?
 
You can use OLEDB to connect to your spreadsheet and fill a DataSet or
DataTable then use the DataSet or DataTable as the DataSource for a DataGrid
control.

Alternatively, you could create a Web Custom Control with appropriate nested
loops to extract your data regardless of how many columns there are.

Do you have some samples of what you are doing now?

I know this isn't much, but you haven't given us much to work with on what
you are doing up to now.

HTH

DalePres
MCAD, MCDBA, MCSE
 
Hi DalePres,

First of all thanks for your early response....

My problem its that i cant use OLEDB to connect to your spreadsheet and fill
a DataSet.

We are forced to use a object created in our company to rescue ranges of
data from excel...
This object returns an array of arrays (jagged array), and its the only way
to rescue data that we have...

Taking in count that the only way its get all data from excel, in a jagged
array... What could be a good way to automatize the layout of all the
applications?...
 
Here's a quick way to do it by just iterating the data into a table. You
could also iterate the data into a DataTable and set the DataSource of a
DataGrid to the DataTable as well.

HTH

DalePres

protected System.Web.UI.WebControls.Table Table1;


private void Page_Load(object sender, System.EventArgs e)

{

// creating jagged array for demo purposes

string [][]arr=new string[4][];

arr[0]=new string[3];

arr[1]=new string[2];

arr[2]=new string[5];

arr[3]=new string[4];

int z = 0;

for(int i=0 ; i < arr.Length ; i++)

{

for(int x=0 ; x < arr.Length ; x++)

{

arr[x]=z.ToString();

z++;

}

}


// dynamically populating the table with the array contents.

for(int x=0 ; x < arr.Length ; x++)

{

TableRow row = new TableRow();

for(int y=0 ; y < arr[x].Length ; y++)

{

TableCell cell = new TableCell();

// Adding some color just to make the

// cells easier to distinguish on the page

cell.BorderStyle = BorderStyle.Solid;

cell.BorderWidth = 1;

cell.BorderColor = Color.Blue;

cell.Text = arr[x][y];

row.Cells.Add(cell);

}

Table1.Rows.Add(row);

}
 
Back
Top