如何使用visual c#从excel到windows窗体的列表框中获取A,B,C等列标题名称# [英] how to fetch column header names like A,B,C...from excel to listbox of windows form by using visual c#
本文介绍了如何使用visual c#从excel到windows窗体的列表框中获取A,B,C等列标题名称#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
有一个看看这个
http://www.aspforums.net/Threads/505299/Read-the-Column-Values-of-the-Header-Row- in-Excel-2003-and-2007-file-C /
我已经解决了它我自己。
Microsoft.Office.Interop.Excel.Worksheet activeSheet =
(Microsoft.Office.Interop.Excel。工作表)Globals.ThisAddIn.Application.ActiveSheet;
如果从组合框中使用,则需要
,
Excel.Range rng = activeSheet.UsedRange.Columns [ + comboBox2.SelectedItem + < span class =code-string> ,System.Type.Missing];
rng.Select();
或
Excel.Range rng = activeSheet.UsedRange.Columns [ A,System.Type 。失踪];
rng.Select();
它适用于我。
hello everyone. I am developing a excel plugin in which i have a window form which contains listbox and a button. I want to fetch excel column headers of activesheet like A,B,C,etc. in the listbox alonwith full column values on button click. I searched a lot on it but did not found anything.I am using visual studio 2010 (visual c#) I will be really thankful for any help.
解决方案
Have a look at this
http://www.aspforums.net/Threads/505299/Read-the-Column-Values-of-the-Header-Row-in-Excel-2003-and-2007-file-C/
i have solved it by myself.
Microsoft.Office.Interop.Excel.Worksheet activeSheet = (Microsoft.Office.Interop.Excel.Worksheet)Globals.ThisAddIn.Application.ActiveSheet;
if use from combobox then,
Excel.Range rng = activeSheet.UsedRange.Columns["" + comboBox2.SelectedItem + "", System.Type.Missing]; rng.Select();
or
Excel.Range rng = activeSheet.UsedRange.Columns["A", System.Type.Missing]; rng.Select();
it works fine for me.
这篇关于如何使用visual c#从excel到windows窗体的列表框中获取A,B,C等列标题名称#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文