I am writing program in C# to copy excel sheet data into email with the original format of the cells. (Text Format Color and cell border as table - not formula)
This is what I coded in C#.
xlApp = new Excel.Application()
xlWorkBook = xlApp.Workbooks.Open("C:\\Projects\\Data\\Rev.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(3);
range = xlWorkSheet.UsedRange;
for (rCnt = 3; rCnt <= 13; rCnt++)
{
for (cCnt = 5; cCnt <= 6; cCnt++)
{
exceldata[ai] = "XX";
if ((range.Cells[rCnt, cCnt] as Excel.Range).Value2 != null)
{
exceldata[ai] = (range.Cells[rCnt, cCnt] as Excel.Range).Text;
str += exceldata[ai];
str += "\n";
}
ai++;
}
}
I did it with range.Value2 method of excelsheet object. But than I had to create html source code file and had to set all cells value into it. But I lost original format of the cells. I think I can do it better than this with Range.FormatConditions method. But don't know how to implement it. Any help please?