如何在一个单元格中转换字符串编号并将每个数字放在新列中 [英] How to convert string number in one cell and put each number in new column

查看:65
本文介绍了如何在一个单元格中转换字符串编号并将每个数字放在新列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在一个单元格中转换字符串编号并将每个数字放在新列中



如果行或单元格包含 123456 然后如何将其转换为 1 2 3 4 5 6



我是什么尝试过:



一二三四有五六
1 2 3 4 5 6

解决方案

获取每个角色并进行转换 - 这很简单:

  string  s =   123456; 
int [] digits = new int [s.Length];
int i = 0 ;
foreach char c in s)
{
digits [i ++] =( int )Char.GetNumericValue(c);
}

或者:

  string  s =   123456; 
int [] digits = new int [s.Length];
for int i = 0 ; i < s.Length; i ++)
{
digits [i] =( int )Char.GetNumericValue(s,i);
}

然后你可以用实际数字值做你喜欢的事。


引用:

如何在一个单元格中转换字符串数字并将每个数字放在新列中



首先你需要提取每个字符(数字)你希望从字符串,函数 substring 应该做的伎俩。

SQL Server Functions [ ^


How to convert string number in one cell and put each number in new column

If row or cell contain 123456 then how to convert it in to 1 2 3 4 5 6

What I have tried:

one two three four five six
1    2    3      4   5   6  

解决方案

Get each character, and convert it - it's simple:

string s = "123456";
int[] digits = new int[s.Length];
int i = 0;
foreach (char c in s)
    {
    digits[i++] = (int) Char.GetNumericValue(c);
    }

Or:

string s = "123456";
int[] digits = new int[s.Length];
for (int i = 0; i < s.Length; i++)
    {
    digits[i] = (int) Char.GetNumericValue(s, i);
    }

You can then do what you like with the actual digit values.


Quote:

How to convert string number in one cell and put each number in new column


First you need to extract each char (digit) you want from the string, the function substring should do the trick.
SQL Server Functions[^]


这篇关于如何在一个单元格中转换字符串编号并将每个数字放在新列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆