excel文件导出|怎么把excel里的文件导出

excel文件导出|怎么把excel里的文件导出的第1张示图

『壹』 导出excel的几种方法

方案一: 通过OleDB方式获取Excel文件的数据,然后通过DataSet中转到SQL ServeropenFileDialog = new OpenFileDialog();openFileDialog.Filter = "Excel files(*.xls)|*.xls";if(openFileDialog.ShowDialog()==DialogResult.OK){FileInfo fileInfo = new FileInfo(openFileDialog.FileName);string filePath = fileInfo.FullName;string connExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=Excel 8.0";try{OleDbConnection oleDbConnection = new OleDbConnection(connExcel);oleDbConnection.Open();//获取excel表DataTable dataTable = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);//获取sheet名,其中[0][1]…[N]: 按名称排列的表单元素string tableName = dataTable.Rows[0][2].ToString().Trim();tableName = "[" + tableName.Replace("'","") + "]";//利用SQL语句从Excel文件里获取数据//string query = "SELECT classDate,classPlace,classTeacher,classTitle,classID FROM " + tableName;string query = "SELECT 日期,开课城市,讲师,课程名称,持续时间 FROM " + tableName;dataSet = new DataSet();//OleDbCommand oleCommand = new OleDbCommand(query, oleDbConnection);//OleDbDataAdapter oleAdapter = new OleDbDataAdapter(oleCommand);OleDbDataAdapter oleAdapter = new OleDbDataAdapter(query,connExcel);oleAdapter.Fill(dataSet,"gch_Class_Info");//dataGrid1.DataSource = dataSet;//dataGrid1.DataMember = tableName;dataGrid1.SetDataBinding(dataSet,"gch_Class_Info");//从excel文件获得数据后,插入记录到SQL Server的数据表DataTable dataTable1 = new DataTable();SqlDataAdapter sqlDA1 = new SqlDataAdapter(@"SELECT classID, classDate,classPlace, classTeacher, classTitle, rativeDate FROM gch_Class_Info",sqlConnection1);SqlCommandBuilder sqlCB1 = new SqlCommandBuilder(sqlDA1);sqlDA1.Fill(dataTable1);foreach(DataRow dataRow in dataSet.Tables["gch_Class_Info"].Rows){DataRow dataRow1 = dataTable1.NewRow();dataRow1["classDate"] = dataRow["日期"];dataRow1["classPlace"] = dataRow["开课城市"];dataRow1["classTeacher"] = dataRow["讲师"];dataRow1["classTitle"] = dataRow["课程名称"];dataRow1["rativeDate"] = dataRow["持续时间"];dataTable1.Rows.Add(dataRow1);}Console.WriteLine("新插入 " + dataTable1.Rows.Count.ToString() + " 条记录");sqlDA1.Update(dataTable1);oleDbConnection.Close();}catch(Exception ex){Console.WriteLine(ex.ToString());}}//方案二: 直接通过SQL语句执行SQL Server的功能函数将Excel文件转换到SQL Server数据库OpenFileDialog openFileDialog = new OpenFileDialog();openFileDialog.Filter = "Excel files(*.xls)|*.xls";SqlConnection sqlConnection1 = null;if(openFileDialog.ShowDialog()==DialogResult.OK){string filePath = openFileDialog.FileName;sqlConnection1 = new SqlConnection();sqlConnection1.ConnectionString = "server=(local);integrated security=SSPI;initial catalog=Library";//import excel into SQL Server 2000/*string importSQL = "SELECT * into live41 FROM OpenDataSource" + "('Microsoft.Jet.OLEDB.4.0','Data Source=" + "\"" + "E:\\022n.xls" + "\"" + "; User ID=;Password=; Extended properties=Excel 5.0')…[Sheet1$]";*///export SQL Server 2000 into excelstring exportSQL = @"EXEC master..xp_cmdshell'bcp Library.dbo.live41 out " + filePath + "-c -q -S" + "\"" + "\"" +" -U" + "\"" + "\"" + " -P" + "\"" + "\"" + "\'";try{sqlConnection1.Open();//SqlCommand sqlCommand1 = new SqlCommand();//sqlCommand1.Connection = sqlConnection1;//sqlCommand1.CommandText = importSQL;//sqlCommand1.ExecuteNonQuery();//MessageBox.Show("import finish!");SqlCommand sqlCommand2 = new SqlCommand();sqlCommand2.Connection = sqlConnection1;sqlCommand2.CommandText = exportSQL;sqlCommand2.ExecuteNonQuery();MessageBox.Show("export finish!");}catch(Exception ex){MessageBox.Show(ex.ToString());}}if(sqlConnection1!=null){sqlConnection1.Close();sqlConnection1 = null;}//方案三: 通过到入Excel的VBA dll,通过VBA接口获取Excel数据到DataSetOpenFileDialog openFile = new OpenFileDialog();openFile.Filter = "Excel files(*.xls)|*.xls";ExcelIO excelio = new ExcelIO();if(openFile.ShowDialog()==DialogResult.OK){if(excelio!=null)excelio.Close();excelio = new ExcelIO(openFile.FileName);object[,] range = excelio.GetRange();excelio.Close();DataSet ds = new DataSet("xlsRange");int x = range.GetLength(0);int y = range.GetLength(1);DataTable dt = new DataTable("xlsTable");DataRow dr;DataColumn dc;ds.Tables.Add(dt);for(int c=1; c<=y; c++){dc = new DataColumn();dt.Columns.Add(dc);}object[] temp = new object[y];for(int i=1; i<=x; i++){dr = dt.NewRow();for(int j=1; j<=y; j++){temp[j-1] = range[i,j];}dr.ItemArray = temp;ds.Tables[0].Rows.Add(dr);}dataGrid1.SetDataBinding(ds,"xlsTable");if(excelio!=null)excelio.Close();}

『贰』 共享文档怎么导出excel

今天就来给大家介绍一下腾讯共享文档,怎么导出为excel是如何操作的吧。

1、首先打开QQ,点击我的文件。

『叁』 excel怎么导出文件

excel导出文件操作如下:

点击 office 按钮,然后另存为 可选多种格式 ,根据工作需要选择即可

如图:

『肆』 怎么把excel里的文件导出

如果想把EXCEL中的文件导出来的话,可以点击菜单中的文件命令选项,点击下拉菜单,找到导入EXCEL中文件的选项,然后点击打开,这样就可以对EXCEL中的文件进行导出的

『伍』 如何将excel导出成word

您好,方法1、点击“文件”,选择“另存为”,点击“浏览”。2、找到存放的文件夹,将保存类型改为“网页(.*htm;*.html)”,点击“保存”。3、在弹出的对话框,点击“是”。4、关闭excel文件,打开“word文档”,点击“文件”。5、选择“打开”,点击“浏览”。6、找到刚刚保存的文件,点击“打开”。7、将文件的保存类型改为“.doc”类型,点击“保存”。

『陆』 Excel里的数据如何导出

excel数据导出有很多种形式,以2013版为例:

文件另存为

文件名输入文件名称

保存类型 选择相应的类型 保存

『柒』 怎么导出EXCEL

单击“导出excel”选项,然后选择好储存位置,关闭表格,找到相应的储存位置即可。

『捌』 excel如何将多个工作簿导出

如果需要将多个宏vba代码从一个工作簿导出到另一个工作簿,则可以正常逐个复制它们。 但这将耗费时间,本文,我将讨论如何快速将所有宏从一个工作簿导出到另一个工作簿并将宏文件保存到特定文件夹。使用VBA代码将所有宏从一个工作簿导出到另一个工作簿 使用VBA代码将所有宏从一个工作簿导出到另一个工作簿要将所有宏vba代码从一个Excel文件导出到另一个Excel文件,请执行以下步骤:1。 首先,您应该同时打开两个工作簿,一个包含宏,另一个是您要导出宏的工作簿,请参见屏幕截图:2。 按住 ALT + F11键打开 Microsoft Visual Basic for Applications窗口。3。 点击插页> 模块,并将以下宏粘贴到 模块窗口。VBA代码:将所有宏从一个工作簿导出到另一个工作簿: Sub ExportAndImportMole()Dim xStrSWSName, xSreDWSName As StringDim xSWS, xDWS As WorkbookxStrSWSName = "old-workbook"xSreDWSName = "new-workbook"Dim xFilePath As StringDim xObjFD As FileDialogSet xObjFD = Application.FileDialog(msoFileDialogFolderPicker)With xObjFD.AllowMultiSelect = False.ShowIf .SelectedItems.Count > 0 ThenxFilePath = .SelectedItems.Item(1)ElseExit SubEnd IfEnd WithOn Error GoTo Err1Set xSWS = Workbooks(xStrSWSName& ".xlsm")Set xDWS = Workbooks(xSreDWSName& ".xlsm")Set xvbap = xSWS.VBProjectSet xVBC = xvbap.VBComponentsFor Each Mole In xSWS.VBProject.VBComponentsIf Mole.Type = vbext_ct_StdMole ThenMole.Export (xFilePath& ""& Mole.Name& ".bas")xDWS.VBProject.VBComponents.Import (xFilePath& ""& Mole.Name& ".bas")End IfNext MoleExit SubErr1:MsgBox "come to nothing!"End Sub注意:在上面的代码中,“旧的工作簿“是要从中导出宏的工作簿的名称,”新的工作簿“是您要导入宏的工作簿。 您应该将名称更改为您自己的名称。 这两本工作簿都应该是 XLSM 文件格式。4。 粘贴上面的代码后,按 F5运行这个代码的关键,和一个 浏览窗口显示,请选择一个文件夹放置导出的宏文件,见截图:5。 然后点击 OK按钮,并且所有宏已从指定的工作簿导出到另一个Excel文件,并且宏文件也已保存到特定文件夹中。 查看截图:注意:此代码只能从正常模块导出宏。

『玖』 怎么把excel导出pdf文件

如果你用2007版或以上的EXCEL软件、WPS电子表格系统,可将EXCEL文档另存PDF格式即可。如果你用的是2003版或以下的EXCEL软件,请安装Adobe Acrobat XI Pro软件,用Adobe PDF打印机打印你要输出的内容,即可得到PDF格式文档。

未经允许不得转载:山九号 » excel文件导出|怎么把excel里的文件导出

赞 (0)