Hi,
I am creating a windows application where the user enters a specific task and it gets stored in a excel sheet as report in my documents folder.Now i want to add a functionality so that the user can specify the location where he wants to store the copy of the excel sheet.i.e.reading from the excel sheet in my documents and copying the contents to another excel sheet in the user defined location.I am able to read the contents of my documents excel sheet,but word by word.Can any1 plz help me to write the data into another excel sheet...?
Here is my code for reading excel sheet from my documents excel sheet.
Excell.Application xlApp;
Excell.Workbook xlWorkBook;
Excell.Worksheet xlWorkSheet;
Excell.Range range;
string str = "";
int rCnt = 0;
int cCnt = 0;
xlApp = new Excell.ApplicationClass();
object BlankValue = System.Reflection.Missing.Value;
string docpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string path1 = string.Format(docpath + @"\Report{0:yyyy_MM_dd}.xls",DateTime.Now.Date);
xlWorkBook = xlApp.Workbooks.Open(path1, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excell.Worksheet)xlWorkBook.Worksheets.get_Item(1);
range = xlWorkSheet.UsedRange;
for (rCnt = 1; rCnt <= range.Rows.Count; rCnt++)
{
for (cCnt = 1; cCnt <= range.Columns.Count; cCnt++)
{
str = (string)(range.Cells[rCnt, cCnt] as Excell.Range).Value2;
}
}
Using this,str is able to store only the last word in my sheet.How to add a List or Arraylist to store the entire data...?and how to copy all the data to another sheet..?is it by using streamwriter?help..