本文介绍了使用excellibrary C#隐藏excel列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已下载并在编码中使用了excellibrary。我需要帮助从数据库调用我的函数到excel。我无法隐藏某些列,例如id号。希望你能帮助我。我还需要帮助如何让多个数据库进入同一个excel。
以下是我的编码
public void load_table_exec() // 这用于自动加载表//使用女性
{
string constring = datasource = localhost; port = 3306; username = root; password =;
MySqlConnection conDataBase = new MySqlConnection(constring);
MySqlCommand cmdDataBase = new MySqlCommand( select *来自database1.example;,conDataBase); //
try
{
MySqlDataAdapter sda = new MySqlDataAdapter();
sda.SelectCommand = cmdDataBase;
DataTable dbdataset = new DataTable();
sda.Fill(dbdataset);
BindingSource bSource = new BindingSource();
bSource.DataSource = dbdataset;
dataGridView1.DataSource = bSource;
sda.Update(dbdataset);
DataSet ds = new DataSet( New_DataSet跨度>);
ds.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;
sda.Fill(dbdataset);
ds.Tables.Add(dbdataset);
ExcelLibrary.DataSetHelper.CreateWorkbook( MyExcelFile.xls,ds) ;
}
catch (例外情况)
{
MessageBox.Show(ex.Message);
}
解决方案
I have download and used excellibrary in my coding. i need help in calling my function from database to excel. i cannot hide certain columns such as id number for example.. hope you can help me out. and i also need help how to make multiple database go to into same excel.
below is my coding
public void load_table_exec()// this is use to load table automatically //illi female { string constring = "datasource=localhost; port=3306;username=root;password="; MySqlConnection conDataBase = new MySqlConnection(constring); MySqlCommand cmdDataBase = new MySqlCommand("select * from database1.example ; ", conDataBase); // try { MySqlDataAdapter sda = new MySqlDataAdapter(); sda.SelectCommand = cmdDataBase; DataTable dbdataset = new DataTable(); sda.Fill(dbdataset); BindingSource bSource = new BindingSource(); bSource.DataSource = dbdataset; dataGridView1.DataSource = bSource; sda.Update(dbdataset); DataSet ds = new DataSet("New_DataSet"); ds.Locale = System.Threading.Thread.CurrentThread.CurrentCulture; sda.Fill(dbdataset); ds.Tables.Add(dbdataset); ExcelLibrary.DataSetHelper.CreateWorkbook("MyExcelFile.xls", ds); } catch (Exception ex) { MessageBox.Show(ex.Message); }
解决方案
这篇关于使用excellibrary C#隐藏excel列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!