Click here to Skip to main content
15,881,173 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: can i use a class created by xsd. Pin
Ashfield13-Mar-09 2:25
Ashfield13-Mar-09 2:25 
QuestionHow to apply stylesheet class in EMail HTML format Pin
Deepml12-Mar-09 19:17
Deepml12-Mar-09 19:17 
AnswerRe: How to apply stylesheet class in EMail HTML format Pin
Abhijit Jana12-Mar-09 19:32
professionalAbhijit Jana12-Mar-09 19:32 
GeneralRe: How to apply stylesheet class in EMail HTML format Pin
Deepml12-Mar-09 19:45
Deepml12-Mar-09 19:45 
GeneralRe: How to apply stylesheet class in EMail HTML format Pin
Abhijit Jana12-Mar-09 20:24
professionalAbhijit Jana12-Mar-09 20:24 
GeneralRe: How to apply stylesheet class in EMail HTML format Pin
Deepml12-Mar-09 20:37
Deepml12-Mar-09 20:37 
GeneralRe: How to apply stylesheet class in EMail HTML format Pin
Abhijit Jana12-Mar-09 20:39
professionalAbhijit Jana12-Mar-09 20:39 
QuestionDataGrid to Excel Pin
rakeshs31212-Mar-09 18:34
rakeshs31212-Mar-09 18:34 
Hi,

I have a DataGrid and i am using the code below to read it.It is reading all the records and working fine.But if i want to read only the recods that are currently displaying the grid(for grid paging is there and at a time it is displaying 10 records).After that i am inserting this to excel file.According to the paging i want the recods to insert in excel(ie 1-10 or 10-20 or 30-40) What should i change in the code? Thanksin advance
public void ExportDataToExcel(DataTable datatable, string[] Headers, string SourcePath, string DestinationPath)
	{
		int i, j;
		string strSourceTemplate = "";
		string strDestFileName = "";
		string strHeaders = "";
		string strRow = "";
      
		System.Data.OleDb.OleDbConnection objXlsCon = null;
		System.Data.OleDb.OleDbCommand objCmd;

		try
		{
			objXlsCon = new System.Data.OleDb.OleDbConnection();
//			if (Headers.Length != datatable.Columns.Count)
//			{
//				throw new Exception("Export Headers List and Table columns should be of same length");
//			}
			if (datatable.Rows.Count > 0)
			{
				strSourceTemplate = SourcePath;
				strDestFileName = DestinationPath;
				//if (File.Exists(strDestFileName))
				//{
				//    File.Delete(strDestFileName);
				//}
				System.IO.File.Copy(strSourceTemplate, strDestFileName);

				objXlsCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDestFileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;MAXSCANROWS=1;\";";
				objXlsCon.Open();
				objCmd = new System.Data.OleDb.OleDbCommand();
				objCmd.Connection = objXlsCon;

				//getting template headers
				for (i = 0; i < Headers.Length; i++)
				{
					strHeaders += Headers[i].ToString() + ",";
				}
				string s=datatable.Columns[0].ColumnName;
				int k=0;
				//getting values 
				foreach (DataRow drow in datatable.Rows)
				{
					for (j = 0; j < datatable.Columns.Count; j++)
					{
						
						//if(Headers.Length > k)
						//if(drow[j].ToString() != "" && drow[j].ToString().Length<255)
						if(Headers.Length > k)
						{
							if(datatable.Columns[j].ColumnName == Headers[k].ToString())
							{
								if(drow[j].ToString() != "" )//&& drow[j].ToString().Length<255)
								{
									strRow += drow[j].ToString() + "','";
									
								}
								else
								{
									//							if(datatable.Columns[j].DataType.FullName == "System.String" || datatable.Columns[j].DataType.FullName == "System.DateTime")
									strRow +="-'"+",'";
									//							else
									//								strRow +="0"+",";

								}
								k++;
							}
							//k++;
						}
					}
                   
					objCmd.CommandText = "Insert into [Sheet1$] (" + strHeaders.Substring(0, strHeaders.Length - 1) + ") values ('" + strRow.Substring(0, strRow.Length - 3) + "')";
					objCmd.ExecuteNonQuery();
					strRow = "";
					j = 0;
					k=0;
				}

			}
		}
		catch (Exception ex)
		{
			throw ex;
		}
		finally
		{
			objCmd = null;
			objXlsCon.Close();
		}
       
	}

AnswerRe: DataGrid to Excel Pin
kumar_k50812-Mar-09 20:15
kumar_k50812-Mar-09 20:15 
GeneralRe: DataGrid to Excel Pin
rakeshs31212-Mar-09 21:43
rakeshs31212-Mar-09 21:43 
AnswerRe: DataGrid to Excel [modified] Pin
kumar_k50812-Mar-09 23:02
kumar_k50812-Mar-09 23:02 
Questionproblem with xsd serialization Pin
prasadbuddhika12-Mar-09 18:19
prasadbuddhika12-Mar-09 18:19 
AnswerRe: problem with xsd serialization Pin
Expert Coming12-Mar-09 18:28
Expert Coming12-Mar-09 18:28 
GeneralRe: problem with xsd serialization Pin
prasadbuddhika12-Mar-09 18:38
prasadbuddhika12-Mar-09 18:38 
GeneralRe: problem with xsd serialization Pin
Expert Coming12-Mar-09 18:41
Expert Coming12-Mar-09 18:41 
GeneralRe: problem with xsd serialization Pin
prasadbuddhika12-Mar-09 19:05
prasadbuddhika12-Mar-09 19:05 
QuestionNo takers on Accordion problem??? Pin
Clay Aldebol12-Mar-09 14:49
Clay Aldebol12-Mar-09 14:49 
AnswerRe: No takers on Accordion problem??? Pin
Expert Coming12-Mar-09 18:26
Expert Coming12-Mar-09 18:26 
GeneralRe: No takers on Accordion problem??? Pin
Clay Aldebol13-Mar-09 3:18
Clay Aldebol13-Mar-09 3:18 
AnswerRe: No takers on Accordion problem??? Pin
Clay Aldebol16-Mar-09 8:24
Clay Aldebol16-Mar-09 8:24 
AnswerRe: No takers on Accordion problem??? Pin
Clay Aldebol16-Mar-09 9:14
Clay Aldebol16-Mar-09 9:14 
QuestionFileUpload Pin
Illegal Operation12-Mar-09 14:04
Illegal Operation12-Mar-09 14:04 
AnswerRe: FileUpload Pin
Christian Graus12-Mar-09 15:01
protectorChristian Graus12-Mar-09 15:01 
AnswerRe: FileUpload Pin
Yusuf12-Mar-09 16:50
Yusuf12-Mar-09 16:50 
QuestionDisable a button a web form. Pin
AndieDu12-Mar-09 13:39
AndieDu12-Mar-09 13:39 

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.