110,567
社区成员
发帖
与我相关
我的任务
分享
string strSql = "insert into f_form (name,flag) values (select name,flag from [sheet1$] in " + @"'C:\\mypath\\新建 Microsoft Excel 工作表.xls' 'Excel 8.0;')"
或者
string strSql = "insert into f_form (name,flag) values (select name,flag from [sheet1$] in 'C:\\\\mypath\\\\新建 Microsoft Excel 工作表.xls' 'Excel 8.0;'"
insert into f_form (name,flag) values (select name,flag from [sheet1$] in 'C:\mypath\新建 Microsoft Excel 工作表.xls' 'Excel 8.0;')
必须写成双反斜杠,如下insert into f_form (name,flag) values (select name,flag from [sheet1$] in 'C:\\mypath\\新建 Microsoft Excel 工作表.xls' 'Excel 8.0;')
要达到这种效果,就必须在代码文件中把双反斜杠“\\”按原意传入SQL语句中,如下insert into f_form (name,flag) values (select name,flag from [sheet1$] in " + @"'C:\\mypath\\新建 Microsoft Excel 工作表.xls' 'Excel 8.0;')
或者
insert into f_form (name,flag) values (select name,flag from [sheet1$] in 'C:\\\\mypath\\\\新建 Microsoft Excel 工作表.xls' 'Excel 8.0;'
sql = "insert into userinfo select userName,userAccount,userStatus from [userinfo$] in '" & Server.MapPath("hbwlUserInfo.xls")
& "' 'Excel 8.0;' where userAccount is not null"
insert into f_form (name,flag) values (select name,flag from [sheet1$] in 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\print\新建 Microsoft Excel 工作表.xls' 'Excel 8.0;')
sql = "insert into userinfo select userName,userAccount,userStatus from [userinfo$] in '" & Server.MapPath("hbwlUserInfo.xls")
insert into f_form select name,flag from [sheet1$] in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\print\新建 Microsoft Excel 工作表.xls
bool rowHeadersVisible = dataGridView1.RowHeadersVisible;
dataGridView1.Focus();
dataGridView1.SelectAll();
dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
dataGridView1.RowHeadersVisible = false;
SendKeys.SendWait("^c");
var xlsapp = new Excel.Application();
var workbook = xlsapp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
var sheet1 = (Microsoft.Office.Interop.Excel._Worksheet)workbook.Sheets[1];
Excel.Range cell = (Excel.Range)sheet1.Cells[1, 1];
xlsapp.Visible = true;
cell.Select();
SendKeys.SendWait("^v");
dataGridView1.RowHeadersVisible = rowHeadersVisible;
Clipboard.Clear();