Code
Protected void exportToExcelClient (IDictionary <string, string> map)
{
If (map. Count = 0)
{
MessageBox. Show ("select the field to export! "," Prompt ", MessageBoxButtons. OK, MessageBoxIcon. Information );
Return;
}
PgbClient. Value = 0;
_ Excel = new Excel. Application ();
Excel. Workbook wbook = _ excel. Workbooks. Add (Missing. Value );
Excel. Worksheet wsheet = (Excel. Worksheet) _ excel. ActiveSheet;
Excel. Range range = (Excel. Range) wsheet. Cells;
Excel. Range ran = null;
String tofilepath = Application. StartupPath + "\ Excel_save \";
String tofilename = "customer.xls ";
String SQL = "SELECT ";
ArrayList keyArr = new ArrayList ();
Foreach (KeyValuePair <string, string> entry in map)
{
SQL + = entry. Value + ",";
KeyArr. Add (entry. Key );
}
SQL = SQL. Substring (0, SQL. Length-1 );
SQL + = "FROM tb_ClientInfo WHERE 1 = 1" + condition;
// MessageBox. Show (SQL );
DataSet myds = boperate. getds (SQL, "tb_Client ");
DataTable dt = myds. Tables ["tb_Client"];
For (int I = 0; I <keyArr. Count; I ++)
{
Ran = (Excel. Range) range [1, I + 1];
Ran. Font. Bold = true;
Ran. Font. Size = 10;
Ran. Value2 = keyArr [I];
// Ran. Columns. AutoFit ();
NAR (ran );
PgbClient. Step =