[英]How could I set multi-line text in an Excel textbox using C#
Here my code: 这是我的代码:
using Excel = Microsoft.Office.Interop.Excel;
private void button1_Click(object sender, EventArgs e)
{
Excel.Application xlApp = new Excel.Application();
Excel.Workbook wb = xlApp.Workbooks.Add(System.Type.Missing);
Excel.Worksheet ws = (Excel.Worksheet)wb.Sheets[1];
xlApp.Visible = true;
Excel.Shape textBox = ws.Shapes.AddTextbox(
Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal,
10 + 10 + 10, 36, 600, 100);
textBox.TextFrame.Characters(System.Type.Missing, System.Type.Missing).Text
= "testing";
xlApp.ActiveWindow.Activate();
xlApp.UserControl = true;
ws = null;
wb = null;
xlApp = null;
}
But with this code I only can add one line text "testing": 但是使用这段代码我只能添加一行文本“testing”:
---------------------------------
|Testing |
| |
| |
---------------------------------
Now I want to add 3 line text, like this: 现在我要添加3行文本,如下所示:
---------------------------------
|Test1 |
|Test2 |
|Test3 |
---------------------------------
Somebody help me? 来人帮帮我?
System.Environment.NewLine
可能是您要分离3个字符串的常量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.