Sunday, July 28, 2013

How to convert class to xml in c#


public void SerializeToXML(yourclass obj)
 {
   XmlSerializer serializer = new XmlSerializer(typeof(yourclass));
   TextWriter txtWriter = new StreamWriter(@"Physicaladdress\fielName.xml");
   serializer.Serialize(txtWriter, obj);
   txtWriter.Close();
 }

Thursday, July 25, 2013

How to use ExtremeML dll in c# for excel sheet reading



using ExtremeML.Packaging;
public void Upload()
       {

           HttpPostedFileBase flExcell = Request.Files["flExcell"];
           if (flExcell.ContentLength != 0)
           {
               string Extenstion = Path.GetExtension(flExcell.FileName);
               string ExcelName = MethodFactory.GenerateUniqueFileName("Excel") + Extenstion.ToString();
               string FilePath = "~/UploadExcel/" + ExcelName;
               flExcell.SaveAs(Server.MapPath(FilePath));


               using (var package = SpreadsheetDocumentWrapper.Open(@FilePhysicalAddress + ExcelName))
               {
                   var part = package.WorkbookPart.WorksheetParts["Sheet1"];
                   
                   foreach (var row in part.Worksheet.SheetData.Rows)
                   {
                       if (row.RowIndex > 1 && row.RowIndex < part.Worksheet.SheetData.Rows.Count())
                       {

                           string Module = row.GetCellValue<string>(0);
                           string TopicContent = row.GetCellValue<string>(1);
                           string TGroup = row.GetCellValue<string>(2);
                           string TGroupComplexity = row.GetCellValue<string>(3);
                           string TopicInstructions = row.GetCellValue<string>(4);
                           string QGroupID = row.GetCellValue<string>(5);
                           string PatternID = row.GetCellValue<string>(6);
                           string QGInstructions = row.GetCellValue<string>(7);
                           string Question = row.GetCellValue<string>(8);
                           string Options = row.GetCellValue<string>(9);
                           string CorrectAnswer = row.GetCellValue<string>(10);


                       }
                   }

               }
           }
       }

Search

Custom Search
Protected by Copyscape Plagiarism Software