如何在C#中的Excel单元格中以编程方式插入新行? [英] How to insert programmatically a new line in an Excel cell in C#?

查看:163
本文介绍了如何在C#中的Excel单元格中以编程方式插入新行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Aspose库来创建一个Excel文档。在某些单元格的某处,我需要在文本的两个部分之间插入一行。

I'm using the Aspose library to create an Excel document. Somewhere in some cell I need to insert a new line between two parts of the text.

我尝试过\\\\但是不起作用,只需在单元格中显示两个方形符号。我可以按Alt + Enter在同一个单元格中创建一个新行。

I tried "\r\n" but it doesn't work, just displays two square symbols in cell. I can however press Alt+Enter to create a new line in that same cell.

如何以编程方式插入新行?

How do I insert a new line programmatically?

推荐答案

从Aspose Cells论坛:如何在单元格中使用新的线条?

From the Aspose Cells forums: How to use new line char with in a cell?

提供文本后,您应将单元格的IsTextWrapped样式设置为true

After you supply text you should set the cell's IsTextWrapped style to true

worksheet.Cells[0, 0].Style.WrapText = true;

这篇关于如何在C#中的Excel单元格中以编程方式插入新行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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