Hi there,
I'm using microsoft visual studio 2005, with c# code. I recently downloaded GemBox which is a spreadsheet for excel. I can pass parameters through textboxes, comboboxes, labels...etc and display it on cells in excell. But now Im calling parameters directly from the database...I would like to know how to display it in excel...Here is part of the code I'm working on: (How can I make it work?)
ExcelFile ef = new ExcelFile();
ef.LoadXls("C:/Invoice.xls");
ExcelWorksheet ws = ef.Worksheets[0];
string sqlq = " SELECT Guest.GuestID, Guest.GuestFirstName, Guest.GuestLastName, Guest.GuestAddress, Guest.GuestEmail, Guest.Country, Guest.GuestPhone, Sales.GuestID, Sales.Date, Sales.Quantity, Sales.SaleItem, Sales.SalePrice, Sales.SaleTotal, Sales.SaleDiscount, FROM Guest Sales LEFT JOIN GuestID Sales ON Guest.GuestID = Sales.GuestID WHERE Guest.GuestID && Sales.GuestID = @GuestID ";
myCommand.CommandText = sqlq;
myCommand.Parameters.Add("@GuestID ", SqlDbType.Int).Value = 12345;
myCommand.Parameters.Add("@GuestFirstName ", SqlDbType.VarChar).Value = ws.Cells["D13"].Value;
myCommand.Parameters.Add("@GuestLastName ", SqlDbType.VarChar).Value = ws.Cells["D13"].Value;
myCommand.Parameters.Add("@GuestAddress ", SqlDbType.VarChar).Value = ws.Cells["D14"].Value;
myCommand.Parameters.Add("@GuestEmail ", SqlDbType.VarChar).Value = ws.Cells["D15"].Value;
myCommand.Parameters.Add("@Country ", SqlDbType.VarChar).Value = ws.Cells["H15"].Value;
myCommand.Parameters.Add("@GuestPhone ", SqlDbType.DateTime).Value = ws.Cells["D16"].Value;
myCommand.Parameters.Add("@Date ", SqlDbType.DateTime).Value = ws.Cells["M13"].Value;
myCommand.Parameters.Add("@Quantity ", SqlDbType.Int).Value = ws.Cells["C19"].Value;
myCommand.Parameters.Add("@SaleItem ", SqlDbType.VarChar).Value = ws.Cells["D19"].Value;
myCommand.Parameters.Add("@SalePrice ", SqlDbType.Money).Value = ws.Cells["L19"].Value;
myCommand.Parameters.Add("@SaleTotal ", SqlDbType.Money).Value = ws.Cells["M19"].Value;
myCommand.Parameters.Add("@SaleDiscount ", SqlDbType.VarChar).Value = ws.Cells["L38"].Value;