如何将数据从c#插入excel? [英] how to insert data from c# to excel?

查看:230
本文介绍了如何将数据从c#插入excel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai guys ..



我为检测大小对象构建了intarface。

我从二进制图像中得到大小对象的结果从相机捕获,我需要记录大小的对象数据excel。



我尝试使用excel从我的界面显示和记录大小数据这个代码。

Hai guys..

I'm build intarface for detection size object.
I get result the size object from binary image from camera capture and i need record size object data to excel.

I was tried this code to show and record size data from my interface using excel.

private void dataToolStripMenuItem_Click(object sender, EventArgs e)
        {
                Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();
                Workbook wb = xla.Workbooks.Add(XlSheetType.xlWorksheet);
                Worksheet ws = (Worksheet)xla.ActiveSheet;

                xla.Visible = true;

                ws.Cells[1, 1] = "No";
                ws.Cells[1, 2] = "Size Data";
                
                string[] arraySize;
                arraySize = new string[101];

                for (int i = 3; i != (arraySize.Length); i++)
                {
                    string sizeData = labelSize.Text;
                    ws.Cells[i, 2] = sizeData;
                }





但是当我点击按钮数据时上面的代码只给我一个数据,直到第100行它仍然相同。

并不是我的意思。

当我点击按钮数据时,我需要从inface文本框中的size对象记录到excel,和excel在运行时从界面给我结果大小数据。

那么,任何人都可以帮我获取运行时大小数据并将其记录到excel?



But code above just give me "one data" when i clicked button data and it's still same until rows 100.
And it doesn't what i meant.
I need the size object from the text box in intraface will record to excel when i'm click the button data, and excel give me result size data in runtime from interface.
So, anyone can help me to get runtime size data and record it to excel?

推荐答案

http://www.c-sharpcorner .com / uploadfile / hrojasara / export-datagridview-to-excel-in-C-Sharp / [ ^ ]



http://csharp.net-information s.com/datagridview/csharp-datagridview-load-excel.htm [ ^ ]


这篇关于如何将数据从c#插入excel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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