Click here to Skip to main content
15,914,416 members
Home / Discussions / C#
   

C#

 
GeneralRe: FolderBrowseDialog Pin
AB777130-Jul-06 18:13
AB777130-Jul-06 18:13 
GeneralRe: FolderBrowseDialog Pin
AB777130-Jul-06 18:32
AB777130-Jul-06 18:32 
QuestionMoving app window with FormBorderStyle set to None Pin
QzRz29-Jul-06 1:36
QzRz29-Jul-06 1:36 
AnswerRe: Moving app window with FormBorderStyle set to None Pin
Ravi Bhavnani29-Jul-06 2:02
professionalRavi Bhavnani29-Jul-06 2:02 
AnswerRe: Moving app window with FormBorderStyle set to None Pin
AB777129-Jul-06 2:07
AB777129-Jul-06 2:07 
Questionhow to save image to Database with Datarow ? Pin
hdv21228-Jul-06 23:56
hdv21228-Jul-06 23:56 
QuestionHow to avoid duplicate entries in DataTable. Pin
VenkataRamana.Gali28-Jul-06 23:22
VenkataRamana.Gali28-Jul-06 23:22 
QuestionExport columns from datagridview to Excel Pin
simsen28-Jul-06 22:26
simsen28-Jul-06 22:26 
Hi,

I have found som code on the Internet, which should export my datagridview to Excel. It also do that BUT it only export 4 of my 5 columns to excel (it's column number 4 it doesn't export which is Produkter.PrisExMoms from the database).

The code I use to export is:

#region Fakturalinier
int rIndex = 12;
foreach (DataRow row in dtOrdrelinier.Rows)
{
rIndex++;
int cIndex = 0;
foreach (DataColumn col in dtOrdrelinier.Columns)
{
cIndex++;
xlApp.Cells[rIndex + 1, cIndex] =
row[col.ColumnName].ToString();
}
}

}

#endregion

The code where I put the 5 columns into my datagridview:

#region FelterIDataGridView
// Databinding for the Grid
da2 = new OleDbDataAdapter("SELECT Ordre.Antal,
Ordre.VareNr, Produkter.Varenavn, Produkter.PrisExMoms FROM Produkter INNER
JOIN (Faktura INNER JOIN Ordre ON Faktura.FakturaID = Ordre.FakturaNr) ON
Produkter.VareNr = Ordre.VareNr WHERE FakturaID=@fakid", cn);

da2.SelectCommand.Parameters.Add("@fakid",
OleDbType.Integer);

da2.SelectCommand.Parameters["@fakid"].Value = fakid;

//create datatable
dtOrdrelinier = new DataTable();

//fill datatable
da2.Fill(dtOrdrelinier);

//create colum to hold the sum of other two colums
DataColumn col = new DataColumn("RaekkeBeloeb");
col.DataType = typeof(System.Decimal);
col.Expression = "Antal*PrisExMoms";

//add the colums
dtOrdrelinier.Columns.Add(col);

//bind datatable to grid view
dgrOrdre.DataSource = dtOrdrelinier;
#endregion

Anyone who can see why the column 4 (Produkter.PrisExMoms from the database) doesn't export to excel with the other columns?

Kind regards,
simsen Smile | :)
AnswerRe: Export columns from datagridview to Excel Pin
simsen29-Jul-06 7:17
simsen29-Jul-06 7:17 
QuestionC# code for mobile agent Pin
Shah Khalid28-Jul-06 22:10
Shah Khalid28-Jul-06 22:10 
Questionadding installation key in setup project Pin
Shah Khalid28-Jul-06 22:00
Shah Khalid28-Jul-06 22:00 
QuestionCan an instance return a value? Pin
Mairaaj Khan28-Jul-06 21:48
professionalMairaaj Khan28-Jul-06 21:48 
AnswerRe: Can an instance return a value? Pin
stancrm28-Jul-06 22:24
stancrm28-Jul-06 22:24 
GeneralRe: Can an instance return a value? Pin
Mairaaj Khan28-Jul-06 23:19
professionalMairaaj Khan28-Jul-06 23:19 
GeneralRe: Can an instance return a value? Pin
mav.northwind28-Jul-06 23:24
mav.northwind28-Jul-06 23:24 
GeneralRe: Can an instance return a value? Pin
Mairaaj Khan29-Jul-06 0:29
professionalMairaaj Khan29-Jul-06 0:29 
GeneralRe: Can an instance return a value? Pin
mav.northwind29-Jul-06 3:23
mav.northwind29-Jul-06 3:23 
GeneralRe: Can an instance return a value? Pin
Mairaaj Khan30-Jul-06 22:25
professionalMairaaj Khan30-Jul-06 22:25 
GeneralRe: Can an instance return a value? Pin
Mairaaj Khan31-Jul-06 22:13
professionalMairaaj Khan31-Jul-06 22:13 
GeneralRe: Can an instance return a value? Pin
Colin Angus Mackay29-Jul-06 8:58
Colin Angus Mackay29-Jul-06 8:58 
GeneralRe: Can an instance return a value? Pin
Mairaaj Khan30-Jul-06 22:28
professionalMairaaj Khan30-Jul-06 22:28 
QuestionProblem With TabControl Pin
maaran28-Jul-06 21:40
maaran28-Jul-06 21:40 
QuestionUploading to VSS Pin
AnnnS28-Jul-06 20:45
AnnnS28-Jul-06 20:45 
AnswerRe: Uploading to VSS Pin
leppie28-Jul-06 23:12
leppie28-Jul-06 23:12 
QuestionHow to avoid warning message in outlook Pin
AnnnS28-Jul-06 20:26
AnnnS28-Jul-06 20:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.