예제 #1
0
파일: view.aspx.cs 프로젝트: bangush/csharp
    protected void Page_Load(object sender, EventArgs e)
    {
        string filename = "";

        if (Request.QueryString["filename"] != null)
        {
            filename = Request.QueryString["filename"].ToString();

            if (filename.EndsWith("xlsx", StringComparison.InvariantCultureIgnoreCase))
            {
                SheetList.Visible = true;
                dataGrid.Visible  = true;

                Exceldocument        = new ExcelDocument(filename);
                SheetList.DataSource = Exceldocument.WorkSheets;
                SheetList.DataBind();
            }
            else if (filename.EndsWith("pdf", StringComparison.InvariantCultureIgnoreCase))
            {
                pdfview.Style["display"]  = "block";
                pdfview.Attributes["src"] = "sender.ashx?filename=" + filename;
            }
            else if (filename.EndsWith("jpg", StringComparison.InvariantCultureIgnoreCase))
            {
                image.Style["display"]          = "block";
                image.Style["background-image"] = "url(\"sender.ashx?filename=" + filename + "\")";
            }
        }
        else
        {
            Response.Redirect("mobile.aspx");
        }
    }
예제 #2
0
            /// <summary>
            /// Creates a new <see cref="SheetList"/> instance from a generic list of
            /// <see cref="ExportPart"/>s.
            /// </summary>
            /// <param name="sheets">The sheets to add.</param>
            /// <returns>A new <see cref="SheetList"/>.</returns>
            public static SheetList FromList(List <ExportPart> sheets)
            {
                SheetList sheetList = new SheetList();

                foreach (ExportPart part in sheets)
                {
                    sheetList.AddUnique(part);
                }
                return(sheetList);
            }
예제 #3
0
        // create a list of sheets in the model
        // auto loaded into the listbox
        private bool InitSheetList()
        {
            int idx = -1;
            //			int result = -1;

            //			string activeViewUniqueId = _DBMgr.ActiveGraphicalView.UniqueId;

            SheetData sheetCurrent = null;

            // clear the current list of sheets
            SheetList.Clear();



            foreach (ViewSheet vs in _DBMgr.AllViewSheets())
            {
                sheetCurrent = new SheetData(vs.SheetNumber, vs.Name, vs);

                SheetList.Add(sheetCurrent);

                //				if (vs.UniqueId.Equals(activeViewUniqueId))
                //				{
                //					result = idx;
                //				}
                //
                //				idx++;
            }
            //
            //			if (result == -1) result = 0;
            //
            //			lbxSheets.SelectedIndex = result;


            lbxSheets.Items.SortDescriptions.Add(
                new SortDescription("SheetNumber",
                                    ListSortDirection.Ascending));

            if (_DBMgr.ActiveGraphicalView.ViewType == ViewType.DrawingSheet)
            {
                idx = FindSheetInList(
                    ((ViewSheet)_DBMgr.ActiveGraphicalView).SheetNumber);
            }

            lbxSheets.SelectedIndex = idx;

            return(true);
        }
예제 #4
0
        public new string ToString()
        {
            //System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("zh-CHS");

            StringBuilder excelSB = new StringBuilder();

            //添加固定信息
            excelSB.AppendLine("<?xml version=\"1.0\"?>");
            excelSB.AppendLine("<?mso-application progid=\"Excel.Sheet\"?>");
            excelSB.AppendLine("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"");
            excelSB.AppendLine(" xmlns:o=\"urn:schemas-microsoft-com:office:office\"");
            excelSB.AppendLine(" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"");
            excelSB.AppendLine(" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"");
            excelSB.AppendLine(" xmlns:html=\"http://www.w3.org/TR/REC-html40\">");
            excelSB.AppendLine(" <DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">");
            excelSB.AppendLine("  <Author>Windows 用户</Author>");
            excelSB.AppendLine("  <LastAuthor>Windows 用户</LastAuthor>");
            excelSB.AppendFormat("  <Created>{0}</Created>\n", DateTime.Now.ToString("s"));
            excelSB.AppendFormat("  <LastSaved>{0}</LastSaved>\n", DateTime.Now.ToString("s"));
            excelSB.AppendLine("  <Version>11.00</Version>");
            excelSB.AppendLine(" </DocumentProperties>");
            ///标题样式
            Style headStyle = new Style("s1", "@");

            headStyle.Horizontal = HorizontalType.Center;
            headStyle.Vertical   = VerticalType.Center;
            FontFormat ff = new FontFormat();

            ff.CharSet     = "134";
            ff.FontName    = "宋体";
            ff.Size        = 16;
            headStyle.Font = ff;

            int index = StyleList.Count;

            StyleList.Add(headStyle);
            excelSB.Append(StyleList.ToString());
            //添加标题样式后删除,因为这个非用户控制
            StyleList.Delete(index);

            excelSB.Append(SheetList.ToString());
            excelSB.AppendLine("</Workbook>");

            return(excelSB.ToString());
        }
예제 #5
0
        public void Setup()
        {
            var target = Engine.Object.Construct(Arguments.Empty);

            Engine.Global.FastAddProperty("Excel", target, true, false, true);

            Workbook.Setup(target);
            Sheet.Setup(target);
            SheetList.Setup(target);
            Row.Setup(target);
            RowList.Setup(target);
            Cell.Setup(target);
            CellList.Setup(target);
            Comment.Setup(target);
            Color.Setup(target);
            Font.Setup(target);
            MergeRegionList.Setup(target);
            MergeRegion.Setup(target);
            CellStyleList.Setup(target);
            CellStyle.Setup(target);
        }
예제 #6
0
    void OnWizardCreate()
    {
        string[] dirs = Directory.GetDirectories(texturePath);

        SheetList sl = ScriptableObjectUtility.CreateAssetAtPath <SheetList>("Songs", listDestination);

        SheetObject[] sheetArray = new SheetObject[dirs.Length];

        for (int i = 0; i < dirs.Length; i++)
        {
            string name = new DirectoryInfo(dirs[i]).Name;
            Debug.Log("name = " + name);
            SheetObject so = ScriptableObjectUtility.CreateAssetAtPath <SheetObject> (name, objDestination);
            so.persistentBorderLayerPath  = name + ".border";
            so.persistentFrontOutlinePath = name + ".outline";
            sheetArray[i] = so;
            EditorUtility.SetDirty(so);
        }
        sl.sheetList = sheetArray;
        EditorUtility.SetDirty(sl);
        AssetDatabase.SaveAssets();
    }
예제 #7
0
        public ViewWindow(file filename)
        {
            InitializeComponent();
            if (filename.Name.EndsWith("xlsx"))
            {
                SheetList.Visibility = Visibility.Visible;
                dataGrid.Visibility  = Visibility.Visible;

                fsc.GetExcelDocumentCompleted += (a, b) =>
                {
                    Exceldocument = b.Result;
                    SheetList.SetBinding(ListBox.ItemsSourceProperty, new Binding("WorkSheets")
                    {
                        Source = Exceldocument, BindsDirectlyToSource = true, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.Default
                    });
                };

                fsc.GetExcelDocumentAsync(filename.Name);
            }
            else if (filename.Name.EndsWith("pdf"))
            {
                UriBuilder ub = new UriBuilder(fsc.Endpoint.Address.Uri.AbsoluteUri.Replace("FileService.svc", "sender.ashx"));
                ub.Query = string.Format("filename={0}", filename.Name);

                webbrowser.Visibility = Visibility.Visible;
                webbrowser.NavigateToString("<html><body><iframe src='" + ub.Uri.AbsoluteUri + "&mime=true' id='ifrm' style='width:100%;height:100%;border:solid 10px green;margin:0;padding:0;'></iframe></body></html>");
            }
            else if (filename.Name.ToLower().EndsWith("jpg"))
            {
                UriBuilder ub = new UriBuilder(fsc.Endpoint.Address.Uri.AbsoluteUri.Replace("FileService.svc", "sender.ashx"));
                ub.Query = string.Format("filename={0}", filename.Name);

                ImageSourceConverter isc = new ImageSourceConverter();
                image.Source = isc.ConvertFromString(ub.Uri.OriginalString) as ImageSource;

                image.Visibility = Visibility.Visible;
            }
        }
예제 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sheets"></param>
 /// <returns></returns>
 private static SheetList FixSheetNames(List <ExportPart> sheets)
 {
     return(SheetList.FromList(sheets));
 }