コード例 #1
0
        //In the file descriptions are stored as sharedString
        //so cellValue it's the zeroBased index of the sharedStringTable
        public String[] GetDescriptions_A2A10()
        {
            String[] retVal = new String[9];

            for (int i = 0; i < retVal.Length; i++)
            {
                Row              r        = SheetDataOfTheFirstSheet.Elements <Row>().ElementAt(i + 1);
                Cell             c        = r.Elements <Cell>().ElementAt(0);
                Int32            shsIndex = Convert.ToInt32(c.CellValue.Text);
                SharedStringItem shsItem  = SharedStrings.Elements <SharedStringItem>().ElementAt(shsIndex);
                retVal[i] = shsItem.Text.Text;
            }

            return(retVal);
        }
コード例 #2
0
        //The value it's stored beacause excel does
        //To be shure it's correct you should perform al calculations
        //In this case i'm sure Excel didn't stored the wrong value so..
        public Double GetValue_D11()
        {
            Double retVal = 0.0d;

            Int32 cellIndex = 0;
            //cellIndex it's 0 and not 3, cause A11, B11, C11 are empty cells
            //Another issue to deal with ;-)
            Cell c = SheetDataOfTheFirstSheet.Elements <Row>().ElementAt(10).Elements <Cell>().ElementAt(cellIndex);

            //as example take a look at the value of storedFormula
            String storedFormula = c.CellFormula.Text;
            String storedValue   = c.CellValue.Text;

            NumberFormatInfo provider = new NumberFormatInfo();

            provider.NumberDecimalSeparator = ".";
            provider.NumberGroupSeparator   = ",";
            provider.NumberGroupSizes       = new Int32[] { 3 };

            retVal = Convert.ToDouble(storedValue, provider);

            return(retVal);
        }