How to calculate sheet dimension RRS feed

  • Question

  • Hi 

    I have situation where excel content is having wrong sheet dimension. I need to update the sheet with correct sheet dimension after calculating correct sheet dimension.

    I am using DocumentFormat.OpenXml.Spreadsheet.

    Currently what I am doing is calculating sheet dimension from sheet data.

      string startDimension = workbook.SheetData.Descendants<Spreadsheet.Cell>().FirstOrDefault().CellReference.Value;
      string endDimension = workbook.SheetData.Descendants<Spreadsheet.Cell>().LastOrDefault().CellReference.Value;
      string derivedsheetDimension=string.Format("{0}:{1}", startDimension, endDimension);;
      workbook.Worksheet.SheetDimension.Reference = derivedsheetDimension;

    But I am not sure this is the correct way of calculating sheet dimension. Can any provide any suggestion on this.



    Wednesday, November 28, 2012 8:28 AM