首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在c#中安装excel插件来创建excel电子表格?

如何在c#中安装excel插件来创建excel电子表格?
EN

Stack Overflow用户
提问于 2019-05-17 11:45:00
回答 1查看 100关注 0票数 0

我已经使用epplus库创建了一个excel电子表格。

在此电子表格中,带有下拉列表的列很少。

我需要使这些下拉列表可搜索。我们可以将下拉列表应用于单个单元格,并使用excel函数进行搜索。

但不可能将相同的方法应用于列中的所有单元格。

但这是可以使用excel插件来实现的,比如'excel校园-列表-搜索-插件‘(https://members.excelcampus.com/products/the-list-search-add-in/categories/142180/posts/422610)。

我不希望每个用户在使用从我的应用程序创建的电子表格时都安装excel插件。

当我使用epplus库从我的.NET应用程序创建电子表格时,我希望自动添加插件。

EN

回答 1

Stack Overflow用户

发布于 2019-05-17 11:48:18

你的问题有点令人困惑!也许这对你有帮助:

代码语言:javascript
运行
复制
//Create the data set and table
DataSet ds = new DataSet("New_DataSet");
DataTable dt = new DataTable("New_DataTable");

//Set the locale for each
ds.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;
dt.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;

//Open a DB connection (in this example with OleDB)
OleDbConnection con = new OleDbConnection(dbConnectionString);
con.Open();

//Create a query and fill the data table with the data from the DB
string sql = "SELECT Whatever FROM MyDBTable;";
OleDbCommand cmd = new OleDbCommand(sql, con);
OleDbDataAdapter adptr = new OleDbDataAdapter();

adptr.SelectCommand = cmd;
adptr.Fill(dt);
con.Close();

//Add the table to the data set
ds.Tables.Add(dt);

//Here's the easy part. Create the Excel worksheet from the data set
ExcelLibrary.DataSetHelper.CreateWorkbook("MyExcelFile.xls", ds);
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56179288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档