Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Line meaning

Hi,
What is the meaning of this?
IEnumerable<DocumentFormat.OpenXml.Spreadsheet.Column> ic = cs.Elements<DocumentFormat.OpenXml.Spreadsheet.Column>().Where(r => r.Min == columnIndex).Where(r => r.Max == columnIndex);

Open in new window

SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Chan

ASKER

Many thanks Hengel.
Is it returning one array per relevant spreadsheet columns, by such line?

What is the purpose to 'care' about only 'First()' below?
                                                    IEnumerable<DocumentFormat.OpenXml.Spreadsheet.Column> ic = cs.Elements<DocumentFormat.OpenXml.Spreadsheet.Column>().Where(r => r.Min == columnIndex).Where(r => r.Max == columnIndex);
                                                    if (ic.Count() > 0)
                                                    {
                                                        DocumentFormat.OpenXml.Spreadsheet.Column c = ic.First();
                                                        double cc = c.Width;
                                                        sw.WriteLine("Cell width: {0}", cc.ToString());
                                                    }

Open in new window

First() returns what the name is suggesting: the first (and eventually the only) item from the collection.
this avoids to "loop" on the collection.
To the original line, why does it need to check both Min and Max in there?
I don't know. that is the application logic presumably
it surely tries to consider only cells that are not merged, and at exaclty that position
Is such line only destined to check for non-merged cell? How to detect that relevant cell is a merged cell?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot Hengel. Where is the documentation located at?
sorry, I had not pasted the URL above:
https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column(v=office.14).aspx

you can find such information really quickly, using google, you search this:
DocumentFormat.OpenXml.Spreadsheet.Column site:microsoft.com