OWC在发布网站上出错

时间:2014-06-03 12:03:49

标签: c# asp.net

我开发了网络应用程序。我在服务器上没有办公室,并希望在那里部署我的发布文件夹。

微软办公室对于OWC是疯狂的吗? 如果有,我们可以在没有安装excel的情况下使用它吗?

using System.Web;
using System.IO;
using OWC11;

namespace AspNetResources.Owc
{
    public partial class _default : System.Web.UI.Page
    {

        // ------------------------------------------------------------------
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
                BuildCharts ();
        }

        // ------------------------------------------------------------------
        private void BuildCharts ()
        {
            string[] chartCategoriesArr = new string [] {"Accord Coupe", "Accord Sedan", "Civic Coupe", "Civic Sedan", "Civic Si"};
            string[] chartValuesArr = new string []{"19400", "15900", "13710", "13010", "19070"};

            string chartCategoriesStr = String.Join ("\t", chartCategoriesArr);
            string chartValuesStr = String.Join ("\t", chartValuesArr);

            OWC11.ChartSpaceClass       oChartSpace = new OWC11.ChartSpaceClass ();
            OWC11.ChartChartTypeEnum    chartType;

            /*--------------------------------------------------------------
             * Try using different char types just for fun
             * -------------------------------------------------------------
            chartType = ChartChartTypeEnum.chChartTypeArea;
            chartType = ChartChartTypeEnum.chChartTypeArea3D;
            chartType = ChartChartTypeEnum.chChartTypeBarClustered;
            chartType = ChartChartTypeEnum.chChartTypeBar3D;
            chartType = ChartChartTypeEnum.chChartTypeColumnClustered;
            chartType = ChartChartTypeEnum.chChartTypeColumn3D;
            chartType = ChartChartTypeEnum.chChartTypeDoughnut;
            chartType = ChartChartTypeEnum.chChartTypeLineStacked;
            chartType = ChartChartTypeEnum.chChartTypeLine3D;
            chartType = ChartChartTypeEnum.chChartTypeLineMarkers;
            chartType = ChartChartTypeEnum.chChartTypePie;
            chartType = ChartChartTypeEnum.chChartTypePie3D;
            chartType = ChartChartTypeEnum.chChartTypeRadarSmoothLine;
            chartType = ChartChartTypeEnum.chChartTypeSmoothLine;
            */

            // ------------------------------------------------------------------------
            // Give pie and doughnut charts a legend on the bottom. For the rest of
            // them let the control figure it out on its own.
            // ------------------------------------------------------------------------
            chartType = ChartChartTypeEnum.chChartTypeColumn3D;

            if (chartType == ChartChartTypeEnum.chChartTypePie ||
                chartType == ChartChartTypeEnum.chChartTypePie3D ||
                chartType == ChartChartTypeEnum.chChartTypeDoughnut)
            {
                oChartSpace.HasChartSpaceLegend = true;
                oChartSpace.ChartSpaceLegend.Position = ChartLegendPositionEnum.chLegendPositionBottom;
            }

            oChartSpace.Border.Color = "white";
            oChartSpace.Charts.Add(0);
            oChartSpace.Charts[0].HasTitle = true;
            oChartSpace.Charts[0].Type = chartType;
            oChartSpace.Charts[0].ChartDepth = 125;
            oChartSpace.Charts[0].AspectRatio = 80;
            oChartSpace.Charts[0].Title.Caption = "Pricing Of 2004 Hondas";
            oChartSpace.Charts[0].Title.Font.Bold = true;

            oChartSpace.Charts[0].SeriesCollection.Add(0);
            oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection.Add ();

            // ------------------------------------------------------------------------
            // If you're charting a pie or a variation thereof percentages make a lot
            // more sense than values...
            // ------------------------------------------------------------------------
            if (chartType == ChartChartTypeEnum.chChartTypePie ||
                chartType == ChartChartTypeEnum.chChartTypePie3D ||
                chartType == ChartChartTypeEnum.chChartTypeDoughnut)
            {
                oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasPercentage = true;
                oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasValue = false;
            }
            // ------------------------------------------------------------------------
            // Not so for other chart types where values have more meaning than
            // percentages.
            // ------------------------------------------------------------------------
            else
            {
                oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasPercentage = false;
                oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasValue = true;
            }

            // ------------------------------------------------------------------------
            // Plug your own visual bells and whistles here
            // ------------------------------------------------------------------------
            oChartSpace.Charts[0].SeriesCollection[0].Caption = String.Empty;
            oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].Font.Name = "verdana";
            oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].Font.Size = 10;
            oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].Font.Bold = true;
            oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].Font.Color = "white";
            oChartSpace.Charts[0].SeriesCollection[0].DataLabelsCollection[0].Position = ChartDataLabelPositionEnum.chLabelPositionCenter;

            oChartSpace.Charts[0].SeriesCollection[0].SetData (OWC11.ChartDimensionsEnum.chDimCategories,
                Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral), chartCategoriesStr);

            oChartSpace.Charts[0].SeriesCollection[0].SetData (OWC11.ChartDimensionsEnum.chDimValues,
                Convert.ToInt32(OWC11.ChartSpecialDataSourcesEnum.chDataLiteral), chartValuesStr);

            // ------------------------------------------------------------------------
            // Pick your favorite image format
            // ------------------------------------------------------------------------
            byte[]  byteArr = (byte[]) oChartSpace.GetPicture ("png", 500, 500);

            // ------------------------------------------------------------------------
            // Store the chart image in Session to be picked up by an HttpHandler later
            // ------------------------------------------------------------------------
            HttpContext     ctx = HttpContext.Current;
            string          chartID = Guid.NewGuid ().ToString ();

            ctx.Session [chartID] = byteArr;
            imgHondaLineup.ImageUrl = string.Concat ("chart.ashx?", chartID);
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {    

        }
        #endregion
    }
}

它给出错误

Server Error in '/owc' Application.

Could not load file or assembly 'owc' or one of its dependencies. An attempt was made to load a program with an incorrect format.

1 个答案:

答案 0 :(得分:0)

错误消息表示文件owc.dll或其中一个引用丢失。

检查文件是否为:

  • 位于您的网站项目的bin文件夹中(发布后);
  • GAC中的
  • (C:\ windows \ assembly)。

如果它确实存在,您可以使用Reflector或类似产品查看owc.dll的引用是什么,您也必须检查这些引用。

相关问题