小编Hja*_*r Z的帖子

在文本文件中的特定位置添加新行.

我想在文件中添加特定的文本行.具体在两个边界之间.

如果我想在item1的边界之间添加一行,它会是什么样子的一个例子:

[item1]
2550 coins 995 200000 7
2550 coins 995 200000 7
2550 coins 995 200000 7
2550 coins 995 200000 7
2550 coins 995 200000 7
//Add a line here in between the specific boundaries
[/item1]
[item2]
2550 coins 995 200000 7
2550 coins 995 200000 7
2550 coins 995 200000 8
2550 coins 995 200000 7
2550 coins 995 200000 7
[/item2]
[item3]
2550 coins 995 200000 7
2550 coins 995 200000 7
2550 coins 995 200000 …
Run Code Online (Sandbox Code Playgroud)

c# io streamwriter

11
推荐指数
1
解决办法
3万
查看次数

在Excel工作表中为非连续单元格着色

这是发生的事情:

在此输入图像描述

xlValues被设置为Excel.Range对象.

我也试过以下,都给了我同样的错误:

//xlValueRange = xlSheet...
.get_Range("A1:A5,A15:A25,A50:A65");
.UsedRange.Range["A1:A5,A15:A25,A50:A65"];
.Range["A1:A5,A15:A25,A50:A65"];

xlApp.ActiveWorkbook.ActiveSheet.Range["A1:A5,A15:A25,A50:A65"];
//I have also tried these alternatives with ".Select()" after the brackets and 
//", Type.Missing" inside the brackets

//This works though...
xlSheet.Range["A1:A5"];
Run Code Online (Sandbox Code Playgroud)

我正在尝试重新着色excel表中的特定单元格,我已经通过使用两个循环找到了解决方案,但它太慢了.通过一个30 000个单元格的列需要几分钟.

我之前从未做过这样的事情,而且我用这个教程让我开始.

此解决方案使用bool数组,将要着色的单元格设置为true.(recolored)

//using Excel = Microsoft.Office.Interop.Excel;

xlApp = new Excel.Application();
xlApp.Visible = true;
xlBook = xlApp.Workbooks.Add(Type.Missing);
xlSheet = (Excel.Worksheet)xlBook.Sheets[1];

for (int i = 1; i < columns + 1; i++)
{
    for (int j = 1; j < rows + 1; …
Run Code Online (Sandbox Code Playgroud)

c# excel office-interop

5
推荐指数
1
解决办法
2529
查看次数

用于计算和显示过程的"ETA/ETC"的规范,规则或指南

ETC ="预计完成时间"

我正在计算运行循环所需的时间并向用户显示一些数字,告诉他/她大约需要多长时间才能完成整个过程.我觉得这是一个普通的事情,每个人偶尔会这样做,我想知道你是否有任何指导方针.

这是我目前正在使用的一个例子:

int itemsLeft; //This holds the number of items to run through.
double timeLeft;
TimeSpan TsTimeLeft;
list<double> avrage;
double milliseconds; //This holds the time each loop takes to complete, reset every loop.

//The background worker calls this event once for each item. The total number 
//of items are in the hundreds for this particular application and every loop takes
//roughly one second.
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    //An item has been completed!

    itemsLeft--;
    avrage.Add(milliseconds);

    //Get …
Run Code Online (Sandbox Code Playgroud)

c# winforms

4
推荐指数
1
解决办法
1998
查看次数

标签 统计

c# ×3

excel ×1

io ×1

office-interop ×1

streamwriter ×1

winforms ×1