简体   繁体   English

使用多行Excel单元格进入C#程序

[英]Working with a multi-line Excel Cell into a C# Program

My problem seems to be a simple case, but I can't seem to find any answers on it. 我的问题似乎是一个简单的案例,但我似乎无法找到任何答案。 I'm trying to write a program that will allow me to read Excel files using C# and the Interop method. 我正在尝试编写一个程序,允许我使用C#和Interop方法读取Excel文件。 These Excel files can contain information that has been entered with the use of "Alt-Enter" to create multiple lines within the cell, each line denoting a different value. 这些Excel文件可以包含使用“Alt-Enter”输入的信息,以在单元格内创建多条线,每条线表示不同的值。

Currently my program spits out the contents of the whole cell, but how do I separate out the multiple values in the single cell, so that I am able to work on the individual values? 目前我的程序吐出整个单元格的内容,但是如何在单个单元格中分离多个值,以便我能够处理单个值? Sorry if this has a simple answer, I'm a noob at this! 对不起,如果这有一个简单的答案,我就是这个菜鸟!

你可以使用String.Split函数:

string[] values = ((string) multiLineCell.Value).Split('\n');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM