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.GuestFirs tName, Guest.GuestLast Name, Guest.GuestAddr ess, Guest.GuestEmai l, Guest.Country, Guest.GuestPhon e, Sales.GuestID, Sales.Date, Sales.Quantity, Sales.SaleItem, Sales.SalePrice , Sales.SaleTotal , Sales.SaleDisco unt, FROM Guest Sales LEFT JOIN GuestID Sales ON Guest.GuestID = Sales.GuestID WHERE Guest.GuestID && Sales.GuestID = @GuestID ";
myCommand.Comma ndText = sqlq;
myCommand.Param eters.Add("@Gue stID ", SqlDbType.Int). Value = 12345;
myCommand.Param eters.Add("@Gue stFirstName ", SqlDbType.VarCh ar).Value = ws.Cells["D13"].Value;
myCommand.Param eters.Add("@Gue stLastName ", SqlDbType.VarCh ar).Value = ws.Cells["D13"].Value;
myCommand.Param eters.Add("@Gue stAddress ", SqlDbType.VarCh ar).Value = ws.Cells["D14"].Value;
myCommand.Param eters.Add("@Gue stEmail ", SqlDbType.VarCh ar).Value = ws.Cells["D15"].Value;
myCommand.Param eters.Add("@Cou ntry ", SqlDbType.VarCh ar).Value = ws.Cells["H15"].Value;
myCommand.Param eters.Add("@Gue stPhone ", SqlDbType.DateT ime).Value = ws.Cells["D16"].Value;
myCommand.Param eters.Add("@Dat e ", SqlDbType.DateT ime).Value = ws.Cells["M13"].Value;
myCommand.Param eters.Add("@Qua ntity ", SqlDbType.Int). Value = ws.Cells["C19"].Value;
myCommand.Param eters.Add("@Sal eItem ", SqlDbType.VarCh ar).Value = ws.Cells["D19"].Value;
myCommand.Param eters.Add("@Sal ePrice ", SqlDbType.Money ).Value = ws.Cells["L19"].Value;
myCommand.Param eters.Add("@Sal eTotal ", SqlDbType.Money ).Value = ws.Cells["M19"].Value;
myCommand.Param eters.Add("@Sal eDiscount ", SqlDbType.VarCh ar).Value = ws.Cells["L38"].Value;
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.GuestFirs tName, Guest.GuestLast Name, Guest.GuestAddr ess, Guest.GuestEmai l, Guest.Country, Guest.GuestPhon e, Sales.GuestID, Sales.Date, Sales.Quantity, Sales.SaleItem, Sales.SalePrice , Sales.SaleTotal , Sales.SaleDisco unt, FROM Guest Sales LEFT JOIN GuestID Sales ON Guest.GuestID = Sales.GuestID WHERE Guest.GuestID && Sales.GuestID = @GuestID ";
myCommand.Comma ndText = sqlq;
myCommand.Param eters.Add("@Gue stID ", SqlDbType.Int). Value = 12345;
myCommand.Param eters.Add("@Gue stFirstName ", SqlDbType.VarCh ar).Value = ws.Cells["D13"].Value;
myCommand.Param eters.Add("@Gue stLastName ", SqlDbType.VarCh ar).Value = ws.Cells["D13"].Value;
myCommand.Param eters.Add("@Gue stAddress ", SqlDbType.VarCh ar).Value = ws.Cells["D14"].Value;
myCommand.Param eters.Add("@Gue stEmail ", SqlDbType.VarCh ar).Value = ws.Cells["D15"].Value;
myCommand.Param eters.Add("@Cou ntry ", SqlDbType.VarCh ar).Value = ws.Cells["H15"].Value;
myCommand.Param eters.Add("@Gue stPhone ", SqlDbType.DateT ime).Value = ws.Cells["D16"].Value;
myCommand.Param eters.Add("@Dat e ", SqlDbType.DateT ime).Value = ws.Cells["M13"].Value;
myCommand.Param eters.Add("@Qua ntity ", SqlDbType.Int). Value = ws.Cells["C19"].Value;
myCommand.Param eters.Add("@Sal eItem ", SqlDbType.VarCh ar).Value = ws.Cells["D19"].Value;
myCommand.Param eters.Add("@Sal ePrice ", SqlDbType.Money ).Value = ws.Cells["L19"].Value;
myCommand.Param eters.Add("@Sal eTotal ", SqlDbType.Money ).Value = ws.Cells["M19"].Value;
myCommand.Param eters.Add("@Sal eDiscount ", SqlDbType.VarCh ar).Value = ws.Cells["L38"].Value;