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 Jun 13, 2022 6:44 pm

Hi-

In a cell... I have the value set as 1,2,3,4,5. What method do I get the value to split it into an int[]?

Thanks,
-Thomas

trozzi1957
 
Posts: 5
Joined: Sun Oct 14, 2018 10:58 pm

Mon Jun 13, 2022 6:46 pm

GetText throws a null exception.

trozzi1957
 
Posts: 5
Joined: Sun Oct 14, 2018 10:58 pm

Tue Jun 14, 2022 3:10 am

Hi,

Thank you for your inquiry.
Please refer to the following code to achieve your requirement. If it diesn't help, please provide your sample Excel for investigation.
Code: Select all
 
            Workbook wb = new Workbook();
            wb.LoadFromFile(fileName);
            Worksheet sheet= wb.Worksheets[0];
             //Gets the cell text
            string str = sheet.Range[1, 1].Text;
            //Split into string[]
            string[] arr = str.Split(',');
            int[] result = new int[arr.Length];
            //Convert to int[]
            for (int i=0;i<arr.Length;i++)
            {
                result[i] = Convert.ToInt32(arr[i]);
            }

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Thu Jul 14, 2022 6:27 am

Hi,

Hope you are doing well!
Has your problem been effectively solved now? Could you give us some feedback at your convenience?
Thanks in advance.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Return to Spire.XLS

cron