读书人

导出EXCEL的时候单元格都是#DIV/0!该

发布时间: 2012-03-07 09:13:51 作者: rapoo

导出EXCEL的时候,单元格都是#DIV/0!
我导出的EXCEL文件有的是数字有的是#DIV/0!这是什么问题?怎么修改啊


2002200320042005200620072008200920102011201220132014201520162017
市盈率-17.6-11.2-8.0-15.0-7.6-13.0#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
EV/EBITDA120.638.416.927.0-471.5555.8#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
市净率1.41.31.32.71.22.30.9#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
企业价值/销售收入#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
企业价值/投资资本1.41.11.11.61.22.0#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!

重要财务比率
收入增长率#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
净利润增长率52.7%53.3%-4.7%49.3%18.1%-100.0%#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
EBITDA率#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
净利率#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
债务权益比18.9%77.7%89.7%107.2%40.7%35.3%#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
ROE-12.4%-17.2%-15.2%-27.1%-18.6%0.0%#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!
ROIC-8.1%-7.1%63.0%-76.2%-10.7%#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!#DIV/0!

估值结果
市盈率法
PE62.4
股价0.0

EV/EBITDA倍数法
EV/EBITDA21.1
股价-0.8

公司自由现金流贴现法
WACC6.6%
增长率5.0%
股价#DIV/0!


[解决办法]
你应该给出你的导出代码。
给你两个例子。
例子一:

C# code
using System;using System.Data;using Sweecom.BLL;using System.Collections;using System.Windows.Forms;using Sweecom.Model;using function;namespace Web.function{    /// <summary>    /// MakeReport 的摘要说明。    /// </summary>    public class MakeReport    {        public MakeReport()        {            //            // TODO: 在此处添加构造函数逻辑            //        }        private System.Data.DataTable _dt;        public System.Data.DataTable dt        {            get{return _dt;}            set{_dt = value;}        }        private string _strFilePath;        public string strFilePath        {            get{return _strFilePath;}            set{_strFilePath = value;}        }        private String[] _columnNames;        public String[] ColumnNames        {            get { return _columnNames; }            set { _columnNames = value; }        }        public bool CreatFile()        {            bool cFile = false;;            //            try            //            {            Microsoft.Office.Interop.Excel.ApplicationClass oExcel;                            oExcel = new Microsoft.Office.Interop.Excel.ApplicationClass();            oExcel.UserControl = false;            Microsoft.Office.Interop.Excel.WorkbookClass wb = (Microsoft.Office.Interop.Excel.WorkbookClass)oExcel.Workbooks.Add(System.Reflection.Missing.Value);            for (int j = 0; j < dt.Columns.Count; j++)            {                oExcel.Cells[1, j + 1] = _dt.Columns[j].ToString();            }            for (int i = 0; i < _dt.Rows.Count; i++)            {                DataRow dr = _dt.Rows[i];                for (int j = 0; j < _dt.Columns.Count; j++)                {                                                                oExcel.Cells[i + 2, j + 1] = dr[dt.Columns[j].ToString()].ToString();                                        }            }            wb.Saved = true;            //filename=  "d:/服务器生成文件/"+CompanyID.ToString();            string strFilePath1 = System.Web.HttpContext.Current.Server.MapPath(_strFilePath);            string strFileName =  DateTime.Now.ToString().Replace("-", "").Replace(" ", "").Replace(":", "") + DateTime.Now.Millisecond +".xls";            if (!System.IO.Directory.Exists(strFilePath1))            {                System.IO.Directory.CreateDirectory(strFilePath1);            }                            oExcel.ActiveWorkbook.SaveCopyAs(strFilePath1 + "/" +strFileName);            oExcel.Quit();            System.GC.Collect();            _strFilePath = _strFilePath + "/" + strFileName;            cFile = true;            //            }            //            catch            //            {            //                            //            }            return cFile;        }        public Boolean CreateFile1()        {            Int32 n = 0;            Boolean cFile = false;            try            {                Microsoft.Office.Interop.Excel.ApplicationClass oExcel;                                oExcel = new Microsoft.Office.Interop.Excel.ApplicationClass();                oExcel.UserControl = false;                Microsoft.Office.Interop.Excel.WorkbookClass wb = (Microsoft.Office.Interop.Excel.WorkbookClass)oExcel.Workbooks.Add(System.Reflection.Missing.Value);                for (Int32 num1 = 0; num1 < ColumnNames.Length; num1++)                {                    oExcel.Cells[1, num1 + 1] = ColumnNames[num1].ToString();                }                for (Int32 num1 = 0; num1 < _dt.Rows.Count; num1++)                {                    for (Int32 num2 = 0; num2 < _dt.Columns.Count; num2++)                    {                                                if (_dt.Rows[num1][num2].ToString().Length>1 && _dt.Rows[num1][num2].ToString().Substring(0, 1).Equals("0") && Int32.TryParse(_dt.Rows[num1][num2].ToString(),out n))//首字符是0                                                   oExcel.Cells[num1 + 2, num2 + 1] = "'" + _dt.Rows[num1][num2].ToString();                        else                            oExcel.Cells[num1 + 2, num2 + 1] = _dt.Rows[num1][num2].ToString();                                            }                }                wb.Saved = true;                String strFilePath1 = System.Web.HttpContext.Current.Server.MapPath("../File");                String strFileName = _dt.TableName + ".xls";                if (!System.IO.Directory.Exists(strFilePath1))                {                    strFilePath1 = System.Web.HttpContext.Current.Server.MapPath("../../File");                }                oExcel.ActiveWorkbook.SaveCopyAs(strFilePath1 + "\\" + strFileName);                oExcel.Quit();                System.GC.Collect();                _strFilePath = strFilePath1 + "\\" + strFileName;                cFile = true;            }            catch (Exception ex)            {                throw ex;            }            return cFile;        }        public void Export()        {            if (strFilePath != "")            {                System.IO.FileInfo file = new System.IO.FileInfo(strFilePath);                System.Web.HttpContext.Current.Response.Clear();                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpContext.Current.Server.UrlEncode(file.Name));                System.Web.HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());                System.Web.HttpContext.Current.Response.WriteFile(file.FullName);                System.Web.HttpContext.Current.Response.Write("<script>window.close();</script>");                System.Web.HttpContext.Current.Response.End();            }        }    } }//使用方法string[] columnNames = { "部门编号", "部门", "未支付费用", "已支付费用", "总计" };MakeReport mr = new MakeReport();mr.dt = Datatable;mr.ColumnNames = columnNames;mr.dt.TableName = "哈哈测试";if (mr.CreateFile1()){mr.Export();}
[解决办法]
对呀给出你的导入代码。要不怎么知道那里错了呢?
http://zzk.cnblogs.com/s?w=%E5%AF%BC%E5%87%BAexcel&t=

[解决办法]
up
[解决办法]
UP
[解决办法]
友情up
[解决办法]
数据错误导致的

读书人网 >asp.net

热点推荐