标题:求助MATLAB EXCLE 问题
只看楼主
申静
Rank: 1
等 级:新手上路
帖 子:16
专家分:3
注 册:2009-9-12
结帖率:75%
已结贴  问题点数:20 回复次数:3 
求助MATLAB EXCLE 问题
刚写了一个程序,需要调用excle中的数据,用了下面的语句: x=xlsread('A2009data.xls','sheet1','a1:a2'),但是MATLAB显示:
??? Error using ==> xlsread
Too many input arguments.
不懂为什么,谢谢大家赐教!!!
搜索更多相关主题的帖子: MATLAB EXCLE 
2010-07-23 21:24
南国利剑
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:29
帖 子:1165
专家分:3536
注 册:2010-4-12
得分:10 
这个问题,爱莫能助。
实在惭愧!
帮你高亮几天。

南国利剑
2010-07-24 01:51
申静
Rank: 1
等 级:新手上路
帖 子:16
专家分:3
注 册:2009-9-12
得分:0 
回复 2楼 南国利剑
谢谢!
2010-07-24 08:11
sunyh1999
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:14
帖 子:1178
专家分:3032
注 册:2009-5-17
得分:10 
帮你找到了资料,你看看对不对:
写入Excel内容,参数:excelTable是要导入excel的一个table表

        public static bool SaveDataTableToExcel(System.Data.DataTable excelTable, string filePath)

      {

             Microsoft.Office.Interop.Excel.Application app =

                new Microsoft.Office.Interop.Excel.ApplicationClass();

            try

             {

                 app.Visible = false;

                 Workbook wBook = app.Workbooks.Add(true);

                 Worksheet wSheet = wBook.Worksheets[1] as Worksheet;

               if (excelTable.Rows.Count > 0)

                 {

                    int row = 0;

                     row = excelTable.Rows.Count;

                    int col = excelTable.Columns.Count;

                    for (int i = 0; i < row; i++)

                     {

                        for (int j = 0; j < col; j++)

                         {

                            string str = excelTable.Rows[i][j].ToString();

                             wSheet.Cells[i + 2, j + 1] = str;

                         }

                     }

                 }


                int size = excelTable.Columns.Count;

                for (int i = 0; i < size; i++)

                 {

                     wSheet.Cells[1, 1 + i] = excelTable.Columns[i].ColumnName;

                 }

                //设置禁止弹出保存和覆盖的询问提示框

                 app.DisplayAlerts = false;

                 app.AlertBeforeOverwriting = false;

                //保存工作簿

                 wBook.Save();

                //保存excel文件

                 app.Save(filePath);

                 app.SaveWorkspace(filePath);

                 app.Quit();

                 app = null;

                return true;

             }

            catch (Exception err)

            {

                 MessageBox.Show("导出Excel出错!错误原因:" + err.Message, "提示信息",

                     MessageBoxButtons.OK, MessageBoxIcon.Information);

                return false;

             }

            finally

             {

             }

         }

欢迎来到我的博客:http://blog..cn/noisunyuhong
2010-07-24 09:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-313843-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019734 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved