制表符分隔的文本复制粘贴到Excel [英] Tab Delimited Text Copy Paste To Excel

查看:1023
本文介绍了制表符分隔的文本复制粘贴到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过C#Stringbuilder生成带有适当制表符分隔的文本(换行符,"\ t"等)的文本块,并将该文本显示在Web应用程序中的标记内.如果我将其复制/粘贴到Excel,则所有文本都会粘贴到电子表格的第一列中.

I am generating a block of text via C# Stringbuilder, with appropriately tab-delimited text (new lines, "\t", etc.) and displaying the text within a tag in my web application. If I copy/paste this to Excel, all the text pastes into the first column on the spreadsheet.

如果我将块的外部HTML(Chrome)复制或复制/粘贴到Notepad ++中,然后将其粘贴到Excel,则所有数据都将被整齐地粘贴到单个单元格中-这是此工作的理想结果.谁能告诉我我需要做些什么才能能够从应用程序中复制文本并将其粘贴到Excel中,以便将文本粘贴到单个单元格中(即,保持制表符分隔的格式)?

If I copy the outerHTML of the block (Chrome) or copy/paste into Notepad++ and THEN paste to Excel, all the data pastes neatly into individual cells - which is the desired outcome of this effort. Can anyone tell me what I need to do in order to be able to copy the text from my application and paste it into Excel, so that the text pastes into individual cells (ie, keeps the tab-delimited format)?

推荐答案

我能够将文本写入的元素从div更改为textarea,从而将其粘贴到Excel并保留格式.将tsv从textarea复制/粘贴到以制表符分隔的Excel电子表格中,以便在粘贴时以表格格式保留数据格式.谢谢大家的帮助.

I was able to paste to Excel and keep the format by changing the element my text wrote to from a div to textarea. Copy/paste of tsv from textarea to a tab-delimited Excel spreadsheet keeps the data formatted in tabular format when pasted. Thanks all for the help.

这篇关于制表符分隔的文本复制粘贴到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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