将电子表格值转换为C#中的格式文本(Convert Spreadsheet values to Formated Text in C#)
我在电子表格中有一些值,如下例所示:
我总是至少有2列(可能很多),并且值之间总是有空行。
我想做的事情:复制这两列,粘贴在一个textBox中,当我按下一个按钮时,我希望这个文本的格式如下:
所以,基本上我需要:
- 删除空行
- 两列中的每个值都需要在单引号之间
- 来自同一行(A1和B1)的值之间必须有逗号
- 每行必须以“[”开头,以“]结束,”
- 最后一行不得有结尾逗号。
是的,我需要的是将excel表转换为Java Script矩阵,以便在Selenium Web浏览器自动化上使用。
我已经做了一个帮助我很多的代码,但只是在excel中使用一个列,将其转换为一个简单的javascript向量,这里是代码:
String[] vector = textBox1.Text.Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); String vectorFinal = String.Join("','", vector); textBox2.Text = "'" + vectorFinal + "'"; Clipboard.SetText(textBox2.Text);
我刚刚开始研究C#,这就是为什么我仍然不知道如何去做。 处理多个列涉及TAB字符,这让我疯狂哈哈...提前感谢!
I have some values in a spreadsheet like this example:
I always have at least 2 columns (could be a lot) and also there are always empty lines between the values.
What I want to do: copy these 2 columns, paste in a textBox and when I press a button, I'd like to have this text formatted like this:
So, basically I need:
- Remove empty lines
- Each value from both columns needs to be between single quotes
- The values from the same line (A1 and B1) must have a comma between them
- Each line must start with "[" and end with "],"
- The last line must not have the ending comma.
Yes, what I need is to convert a excel table to a Java Script matrix, to use on Selenium web browser automation.
I already did one code that's helping me a lot, but just with a single column in excel, to convert it to a simple javascript vector, here's the code:
String[] vector = textBox1.Text.Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); String vectorFinal = String.Join("','", vector); textBox2.Text = "'" + vectorFinal + "'"; Clipboard.SetText(textBox2.Text);
I'm just starting to study C#, that's why I still have no idea how to do it. Dealing with multiple columns involve TAB characters that are driving me crazy haha ... thanks in advance!
原文:https://stackoverflow.com/questions/28802241
最满意答案
主mPDF Github页面上的文档适用于开发版本。 还有现成的6.1.0版软件包 ,可以按原样上传和使用。
但是,我建议在本地通过composer安装mPDF,然后通过FTP或您使用的任何方式将整个本地安装传输到您的服务器。
由于作曲家现在是包裹管理的事实上的标准,未来版本的mPDF将不再提供那些预先准备好的包裹。
The documentation on the main mPDF Github page is for development version. There still are ready-to-use packages for version 6.1.0 which can be uploaded and used as-is.
However, I would recommend installing mPDF via composer locally and then transfer the whole local installation to your server via FTP or whatever you use.
As the composer is de-facto standard for package management now, future versions of mPDF will not provide those pre-prepared packages anymore.
相关问答
更多-
默认情况下,NPM依赖关系从NPM存储库中提取。 作者必须手动将其软件的新版本上传到NPM存储库,因此,NPM上托管的代码的“ @latest ”版本与任何地方存在的代码的最新版本(例如,GitHub上)不同。 根据Sails上的NPM存储库信息页面 ,最新的NPM托管版本是0.9.16而当前的GitHub版本是0.10.0-rc3 。 如果你想让你的项目依赖于特定的分支或者提交特定的Git仓库(而不是在NPM仓库中托管的版本),NPM开发者已经包含了一个明确的机制来允许这一点,在“ Git package ...
-
你先运行brew update吗? 如果不这样做,Homebrew无法更新其公式,如果不更新其公式,则不知道如何安装最新版本的软件。 Have you run brew update first? If you don't do that, Homebrew can't update its formulas, and if it doesn't update its formulas it doesn't know how to install the latest versions of softwar ...
-
它确实取决于应用程序设计运行的框架的版本,有几个版本的框架和一些运行时。 有时可以为.NET 3.5编写应用程序,但是引用了针对.NET 1.1编写的库,在这种情况下,您需要同时安装这两个库。 框架,运行时和语言参考有一个公平的分解在这个答案 。 It really depends on what version of the framework that the application was designed to run on, there are a few versions of the fram ...
-
我相信你可以做到以下几点: sudo npm install soap@0.15.0 I believe you can do the following : sudo npm install soap@0.15.0
-
主mPDF Github页面上的文档适用于开发版本。 还有现成的6.1.0版软件包 ,可以按原样上传和使用。 但是,我建议在本地通过composer安装mPDF,然后通过FTP或您使用的任何方式将整个本地安装传输到您的服务器。 由于作曲家现在是包裹管理的事实上的标准,未来版本的mPDF将不再提供那些预先准备好的包裹。 The documentation on the main mPDF Github page is for development version. There still are ready ...
-
你可以使用RVM来安装ruby(它也会帮助你维护版本) 首先安装RVM gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB \curl -sSL https://get.rvm.io -o rvm.sh cat rvm.sh | bash -s stable source ~/.rvm/scri ...
-
你可以做 rvm use ruby --latest --default You can do rvm use ruby --latest --default
-
有两种选择。 最简单的方法可能是从Github安装,使用 devtools::install_github("rforge/rgl", subdir="pkg/rgl") 编辑添加:有一段时间这没有奏效,因为Github镜像没有被更新。 现在看起来好了,但如果它再次死亡,这个答案中描述的三种方法中唯一仍然有效的方法就是使用svn。 这会安装一个可能有几个小时的版本。 它确实需要你有用于源代码安装的工具; rgl有很多需要编译的代码。 这些工具可在Windows上使用, 网址为https://cloud.r ...
-
如何在Ubuntu上安装mongodb-clients最新版本?(How to install mongodb-clients latest version on Ubuntu?)[2022-04-12]
使用他们已经提到的官方MongoDB文档如何安装您选择的版本。 安装Ubuntu 12.04和14.04的步骤 对于Ubuntu 16.04使用此功能 注意: -在此之前,请注意您没有MongoDB的任何现有存储库文件。 您可以使用sudo apt-get update进行检查。如果您有任何更新,则会显示更新。 如果你已经使用sudo rm /etc/apt/sources.list.d/mongodb*.list删除它,然后安装MongoDB On Ubuntu 16.04: sudo apt-key a ... -
确保package.json中有正确的版本,并且您没有将请求缓存到npm注册表。 您可以尝试删除本地(和全局)安装的模块并清除缓存。 还要确保您没有使用代理或私人注册表。 Make sure that you have a correct version in package.json and that you're not caching the requests to the npm registry. You may try to remove the locally (and globally) i ...