Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Apr 08, 2019 5:11 pm

Hello everyone!

How can I get all the values in a particular column and put a list?

Code: Select all
               Workbook content = new Workbook();
                        content.LoadFromFile("Contratação.xls");
                        Worksheet contentSheet = content.Worksheets[0];
                        List<string> numeropropostaExcel = new List<string>();
                       
                        for (int i = 1; i < contentSheet.SelectionCount; i++)
                        {
                         
                            numeropropostaExcel.Add(contentSheet.Range[i, 1].Text.ToString());
                        }

caio687
 
Posts: 1
Joined: Mon Apr 08, 2019 5:07 pm

Tue Apr 09, 2019 6:04 am

Hi,
Thank you for your inquiry.
Please refer to the the following code to achieve your demand. If there is any question, please feel free to write back.
Code: Select all
Workbook content = new Workbook();
content.LoadFromFile("simple.xls");
Worksheet contentSheet = content.Worksheets[0];
List<string> numeropropostaExcel = new List<string>();
// Traverse all the data of the first column
for (int i = 1; i <=contentSheet.LastRow; i++)
{
   numeropropostaExcel.Add(contentSheet.Range[i,1].Value);
 }

Sincerely,
Nancy
E-iceblue support team
Last edited by nancy.yang on Mon May 06, 2019 9:58 am, edited 1 time in total.
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Fri Apr 12, 2019 7:20 am

Hi,

Did my code help you? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Return to Spire.XLS