This project has moved and is read-only. For the latest updates, please go here.

How can i cast a table row into IXLTableRow

Mar 5, 2012 at 4:23 PM
Edited Mar 5, 2012 at 4:24 PM

Hi,

I am using Tables in Sheets to fetching records from excel file, Here is my piece of code 

 

public static List<DistractorQuestion> DistractorQuestionList(IXLTable t)
    {
        List<DistractorQuestion> qList = new List<DistractorQuestion>();
        
 ******** Cannot implicitly convert of type IXLRangeRows to IXLTableRows ***** getting error
       	 IXLTableRows rows = t.RowsUsed();
 ******** Cannot implicitly convert of type IXLRangeRows to IXLTableRows ***** getting error
	foreach (var r in rows)
        {
            if (!r.IsEmpty())
            {
                qList.Add(new DistractorQuestion(r));
            }
        }
        
        return qList;
    }

My code is working well before today, but unexpectedly getting some "DocumentFormat.OpenXML" 
 exception after fixing my above piece of code not working i'm getting an exception my 
lot's of code is based on that line  "IXLTabelRows rows = t.RowsUsed();" 
like 
public GeneralQuestion(IXLTableRow r)
    {
            this.blank = r.Field("blank").GetValue<string>();
            this.id = r.Field("id").GetValue<int>();
            this.text = r.Field("text").GetValue<string>(); 

 }

and in lot's of other classes or functions for different kinds of sheets,.

 

How Can i cast a t.RowsUsed() directly into IXLTableRows???

This help me alot Thanks....

Mar 5, 2012 at 4:46 PM

There was a change in the way tables work. Use:

table.DataRange.RowsUsed()

Mar 6, 2012 at 1:33 PM

Thanks Mdeleon,

The given line of code works for me.