Ejemplo n.º 1
0
        protected void exportDataSetByTemplateBtn_Click(object sender, EventArgs e)
        {
            XmlDocument xmlDoc = WebXmlDocumentCache.GetXmlDocument("Interco upload template.xml");

            xmlDoc.PreserveWhitespace = true;

            WorkbookNode workbook = new WorkbookNode();

            workbook.LoadXml(xmlDoc.OuterXml);

            DataTable table = CreateDemoDataTable();

            DataViewExportOptions options = new DataViewExportOptions()
            {
                ExportColumnHeader = false
            };

            table.DefaultView.FillIntoSpreadSheet(workbook, "Sheet1", options);

            Response.AppendHeader("CONTENT-DISPOSITION",
                                  string.Format("{0};filename={1}", "inline", HttpUtility.UrlEncode("test.xml")));

            Response.ContentType = "text/xml";
            Response.Clear();
            workbook.Save(Response.OutputStream);
            Response.End();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 菜单
        /// </summary>
        private void RenderMenu()
        {
            XmlDocument xmlDoc = WebXmlDocumentCache.GetXmlDocument("../xml/functions.xml");

            Stopwatch sw = new Stopwatch();

            sw.Start();

            try
            {
                if (!xmlDoc.Equals(null))
                {
                    XmlNodeList captions = xmlDoc.DocumentElement.SelectNodes("Item");

                    foreach (XmlElement elemCaption in captions)
                    {
                        string strVisible = elemCaption.GetAttribute("visible").ToLower();

                        if ((strVisible != "false") && CheckUserPermissions(elemCaption))
                        {
                            HtmlGenericControl li = new HtmlGenericControl("li");

                            menuList.Controls.Add(li);

                            HtmlAnchor link = new HtmlAnchor();

                            link.InnerText = elemCaption.GetAttribute("name");
                            link.HRef      = elemCaption.GetAttribute("url");
                            link.Target    = elemCaption.GetAttribute("target");

                            li.Controls.Add(link);
                        }
                    }
                }
            }
            finally
            {
                sw.Stop();
                Debug.WriteLine(string.Format("RenderMenu: {0:#,##0}", sw.ElapsedMilliseconds));
            }
        }