Kalyani Shevale

Kalyani Shevale

  • NA
  • 3.2k
  • 701.3k

how to get 1st column value in spreadsheet Document in mvc

Nov 19 2018 1:20 AM
I have created an Open XML document file
in Existing Spreadsheet document open then read the 1st column value in this file.
  1. SpreadsheetDocument spreadsheetDocument =  
  2.             SpreadsheetDocument.Open(srcFile, true);  
  3.                 WorksheetPart newWorksheetPart = spreadsheetDocument.WorkbookPart.AddNewPart<WorksheetPart>();  
  4.                 newWorksheetPart.Worksheet = new Worksheet(new SheetData());  
  5.                 WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart;  
  6.                 Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>();  
  7.                 string relationshipId = spreadsheetDocument.WorkbookPart.GetIdOfPart(newWorksheetPart);  
  8.                 uint sheetId = 1;  
  9.                 
  10.                 SheetData sheetData = newWorksheetPart.Worksheet.GetFirstChild<SheetData>();  
  11.   
  12.   
  13.                 IEnumerable<WorksheetPart> worksheetPart = workbookPart.WorksheetParts;  
  14.                 int rocount=0;  
  15.                 Sheet sheet = workbookPart.Workbook.Descendants<Sheet>()  
  16.                     .Where(s => s.Name == "Survey Details").FirstOrDefault();  
  17.   
  18.   
  19.                 foreach (WorksheetPart WSP in worksheetPart)  
  20.                 {  
  21.                     //find sheet data  
  22.                     IEnumerable<SheetData> sheetData1 = WSP.Worksheet.Elements<SheetData>();  
  23.                     // Iterate through every sheet inside Excel sheet  
  24.                     foreach (SheetData SD in sheetData1)  
  25.                     {  
  26.                         IEnumerable<Row> row = SD.Elements<Row>(); // Get the row IEnumerator  
  27.                         IEnumerable<Column> column = SD.Elements<Column>();  
  28.                         var d = column.Count();  
  29.                         rocount=(row.Count()); // Will give you the count of rows  
  30.                     }  
  31.                 }  
 
 how to read column value in c#
 

Answers (12)