Exemple #1
0
 public string RunActionByName(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string actionName, object[] args) {
     object[] results = this.Invoke("RunActionByName", new object[] {
                 userName,
                 password,
                 exportStyle,
                 applicationURL,
                 gridURL,
                 actionName,
                 args});
     return ((string)(results[0]));
 }
Exemple #2
0
 public string GetComboListByName(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string comboName, object[] args)
 {
     object[] results = this.Invoke("GetComboListByName", new object[] {
         userName,
         password,
         exportStyle,
         applicationURL,
         gridURL,
         comboName,
         args
     });
     return((string)(results[0]));
 }
Exemple #3
0
 public string RunActionByName(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string actionName, object[] args)
 {
     object[] results = this.Invoke("RunActionByName", new object[] {
         userName,
         password,
         exportStyle,
         applicationURL,
         gridURL,
         actionName,
         args
     });
     return((string)(results[0]));
 }
Exemple #4
0
 /// <remarks/>
 public void GetComboListByNameAsync(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string comboName, object[] args, object userState)
 {
     if ((this.GetComboListByNameOperationCompleted == null))
     {
         this.GetComboListByNameOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetComboListByNameOperationCompleted);
     }
     this.InvokeAsync("GetComboListByName", new object[] {
         userName,
         password,
         exportStyle,
         applicationURL,
         gridURL,
         comboName,
         args
     }, this.GetComboListByNameOperationCompleted, userState);
 }
        public static async Task <ExportResult> ExportSvgAsync(
            ExportStyle style,
            InstalledFont selectedFont,
            CharacterRenderingOptions options,
            Character selectedChar)
        {
            try
            {
                // We want to prepare geometry at 1024px, so force this
                options = options with {
                    FontSize = 1024
                };
                using var typography = options.CreateCanvasTypography();

                // Get save file
                string name = GetFileName(selectedFont, options.Variant, selectedChar, "svg");
                if (await PickFileAsync(name, "SVG", new[] { ".svg" }) is StorageFile file)
                {
                    try
                    {
                        CachedFileManager.DeferUpdates(file);
                        // Generate SVG doc and write to file
                        await Utils.WriteSvgAsync(GetSVG(style, options, selectedChar), file);

                        return(new ExportResult(true, file));
                    }
                    finally
                    {
                        await CachedFileManager.CompleteUpdatesAsync(file);
                    }
                }
            }
            catch (Exception ex)
            {
                await Ioc.Default.GetService <IDialogService>()
                .ShowMessageAsync(ex.Message, Localization.Get("SaveImageError"));
            }

            return(new ExportResult(false, null));
        }
Exemple #6
0
 /// <remarks/>
 public void GetComboListByNameAsync(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string comboName, object[] args, object userState) {
     if ((this.GetComboListByNameOperationCompleted == null)) {
         this.GetComboListByNameOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetComboListByNameOperationCompleted);
     }
     this.InvokeAsync("GetComboListByName", new object[] {
                 userName,
                 password,
                 exportStyle,
                 applicationURL,
                 gridURL,
                 comboName,
                 args}, this.GetComboListByNameOperationCompleted, userState);
 }
Exemple #7
0
 /// <remarks/>
 public void GetComboListByNameAsync(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string comboName, object[] args)
 {
     this.GetComboListByNameAsync(userName, password, exportStyle, applicationURL, gridURL, comboName, args, null);
 }
 private void ExportCurrentData(Excel.ApplicationClass excel,DataSet dsData,ExportStyle style)
 {
     int rowIndex = 1;
     int colIndex = 0;
     int startCol = 0;
     int i=0;
     int eventRow = 1;
     foreach(DataTable dtb in dsData.Tables)
     {
         startCol = colIndex;
         AddDataTableToExcel(excel,dtb,style,ref rowIndex,ref colIndex);
         if(ExportRowProgress!=null)
             ExportRowProgress(eventRow++,dsData.Tables.Count);
         switch(style)
         {
             case ExportStyle.RowWise:
             {
                 colIndex = 0;
                 rowIndex += excelStyle.RowSpaceBetweenTables + 1;
                 break;
             }
             case ExportStyle.ColumnWise:
             {
                 rowIndex = 1;
                 colIndex += excelStyle.ColumnSpaceBetweenTables;
                 break;
             }
             case ExportStyle.SheetWise:
             {
                 if(i != dsData.Tables.Count-1)
                 {
                     excel.Worksheets.Add(
                         Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                 }
                 colIndex = 0;
                 rowIndex = 1;
                 break;
             }
         }
         i++;
     }//For
 }
Exemple #9
0
 /// <remarks/>
 public void RunActionByNameAsync(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string actionName, object[] args)
 {
     this.RunActionByNameAsync(userName, password, exportStyle, applicationURL, gridURL, actionName, args, null);
 }
        /// <summary>
        /// Exports the DataSet to the excel and opens the excel.
        /// </summary>
        /// <param name="dsData">Dataset to be exported</param>
        /// <param name="style">Style specifies Column wise,Row wise or Sheet wise</param>
        public void ExportDataToExcel(DataSet dsData,ExportStyle style)
        {
            Excel.ApplicationClass excel = null;
            Excel.Workbooks workbooks = null;
            Excel.Workbook workbook = null;
            try
            {
                _listrow = new SortedList();
                excel =  new Excel.ApplicationClass();
                excel.Visible = true;
                workbooks = excel.Workbooks;
                workbook = workbooks.Add(true);

                ExportCurrentData(excel,dsData,style);
                _listrow = null;
                Excel.Worksheet worksheet = (Excel.Worksheet)excel.ActiveSheet;
                worksheet.Activate();

                excel.Visible = true;

            }
            catch(Exception ee)
            {
                throw ee;
            }
            finally
            {
                if(workbook!=null) Marshal.ReleaseComObject(workbook);
                if(workbooks!=null) Marshal.ReleaseComObject(workbooks);
                if(excel!=null)Marshal.ReleaseComObject(excel);
                workbook = null;
                workbooks = null;
                excel = null;
            }
        }
        private void AddDataTableToExcel(Excel.ApplicationClass excel,DataTable table,ExportStyle style,ref int rowIndex,ref int columnIndex)
        {
            int colstart = columnIndex;
            int colbak = colstart;
            if(style == ExportStyle.SheetWise)
            {
                Excel.Worksheet worksheet = (Excel.Worksheet)excel.ActiveSheet;
                worksheet.Name = table.TableName;
            }

            /*************** �Header ****************/
            columnIndex += excelStyle.ColumnSpace;
            int col_cnt = table.Columns.Count;
            StringBuilder header_string = new StringBuilder();
            foreach (DataColumn col in table.Columns)
            {
                header_string.Append(col.ColumnName);
                header_string.Append("\t");
            }
            // ����ճ����ϵͳ������
            Clipboard.SetText(header_string.ToString());
            // ѡ��ǰ���sheet
            Excel.Worksheet wsh = (Excel.Worksheet)excel.ActiveSheet;
            // ѡ��Ҫճ�����ݵ����Ͻǵ�Cell
            Excel.Range rng = (Excel.Range)excel.Cells[rowIndex, columnIndex];
            rng.Select();
            // ճ��
            wsh.Paste();

            // ����Range��ʽ
            rng = wsh.Range[excel.Cells[rowIndex, columnIndex], excel.Cells[rowIndex, columnIndex + col_cnt - 1]];
            rng.Select();
            rng.Font.Bold = true;
            rng.Interior.Color = System.Drawing.ColorTranslator.ToOle(excelStyle.HeaderBackColor);
            rng.Font.Color = System.Drawing.ColorTranslator.ToOle(excelStyle.HeaderForeColor);
            rng.Font.Name = excelStyle.FontName;
            rng.Font.Size = excelStyle.FontSize;
            rng.Font.Italic = excelStyle.HeaderItalic;
            rng.Font.Bold = excelStyle.HeaderFontBold;

            /*************** ����� ****************/
            rowIndex++;
            int row_cnt = table.Rows.Count;
            StringBuilder data_string = new StringBuilder();
            foreach (DataRow row in table.Rows)
            {

                foreach (DataColumn col in table.Columns)
                {
                    data_string.Append(row[col.ColumnName].ToString());
                    data_string.Append("\t");
                }
                data_string.Append("\n");   // ��ӻ��з�
            }

            // ����ճ����ϵͳ������
            Clipboard.SetText(data_string.ToString());
            // ѡ��Ҫճ�����ݵ����Ͻǵ�Cell
            rng = (Excel.Range)excel.Cells[rowIndex, columnIndex];
            rng.Select();
            // ճ��
            wsh.Paste();
            // ����Range��ʽ
            rng = wsh.Range[excel.Cells[rowIndex, columnIndex], excel.Cells[rowIndex + row_cnt - 1, columnIndex + col_cnt - 1]];
            rng.Select();
            rng.Font.Color = System.Drawing.ColorTranslator.ToOle(excelStyle.ItemForeColor);
            rng.Font.Name = excelStyle.FontName;
            rng.Font.Size = excelStyle.FontSize;
            rng.Font.Italic = excelStyle.ItemItalic;
            rng.Font.Bold = excelStyle.ItemFontBold;

            /**************ԭ�������Cell By Cell��д��ʽ��Ч�ʵ��£��Ұ����ij�Copy�ַ�������ʽ������ٶ� ***************/
            /*
            foreach(DataColumn col in table.Columns)
            {
                columnIndex+= excelStyle.ColumnSpace ;
                Excel.Range cel = (Excel.Range)excel.Cells[rowIndex,columnIndex];
                cel.Font.Bold = true;
                cel.Interior.Color = System.Drawing.ColorTranslator.ToOle(excelStyle.HeaderBackColor);
                cel.Font.Color =  System.Drawing.ColorTranslator.ToOle(excelStyle.HeaderForeColor);
                cel.Font.Name = excelStyle.FontName;
                cel.Font.Size = excelStyle.FontSize;
                cel.Font.Italic = excelStyle.HeaderItalic;
                cel.Font.Bold = excelStyle.HeaderFontBold;
                excel.Cells[rowIndex,columnIndex]=col.ColumnName;
            }

            foreach(DataRow row in table.Rows)
            {
                rowIndex+= excelStyle.RowSpace;
                foreach(DataColumn col in table.Columns)
                {
                    colstart += excelStyle.ColumnSpace ;

                    Excel.Range cel = (Excel.Range)excel.Cells[rowIndex,colstart];

                    if(rowIndex!= 0 && rowIndex%2 == 0)
                    {
                        if(excelStyle.ItemAlternateBackColor != Color.White)
                            cel.Interior.Color = System.Drawing.ColorTranslator.ToOle(excelStyle.ItemAlternateBackColor);
                    }
                    else
                    {
                        if(excelStyle.ItemBackColor != Color.White)
                            cel.Interior.Color = System.Drawing.ColorTranslator.ToOle(excelStyle.ItemBackColor);
                    }

                    cel.Font.Color =  System.Drawing.ColorTranslator.ToOle(excelStyle.ItemForeColor);

                    cel.Font.Name = excelStyle.FontName;
                    cel.Font.Size = excelStyle.FontSize;
                    cel.Font.Italic = excelStyle.ItemItalic;
                    cel.Font.Bold = excelStyle.ItemFontBold;
                    excel.Cells[rowIndex,colstart]=row[col.ColumnName].ToString();
                }
                colstart = colbak;

            }
            */
            if (!_listrow.ContainsKey(table.Rows.Count))
            {
                _listrow.Add(table.Rows.Count,rowIndex);
            }
        }
Exemple #12
0
 public string GetComboListByName(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string comboName, object[] args) {
     object[] results = this.Invoke("GetComboListByName", new object[] {
                 userName,
                 password,
                 exportStyle,
                 applicationURL,
                 gridURL,
                 comboName,
                 args});
     return ((string)(results[0]));
 }
Exemple #13
0
        private void ExportCurrentData(ExcelPackage excel, IEnumerable <EDataTable> dsData, ExportStyle style)
        {
            var rowIndex = 3;
            var colIndex = 0;


            foreach (var dtb in dsData)
            {
                AddDataTableToExcel(excel, dtb, style, ref rowIndex, ref colIndex);


                switch (style)
                {
                case ExportStyle.RowWise:
                {
                    colIndex  = 0;
                    rowIndex += _excelStyle.RowSpaceBetweenTables + 1;
                    break;
                }

                case ExportStyle.ColumnWise:
                {
                    rowIndex  = 3;
                    colIndex += _excelStyle.ColumnSpaceBetweenTables;
                    break;
                }

                case ExportStyle.SheetWise:
                {
                    //if (i != dsData.Values.Count - 1)
                    //{
                    //    excel.Worksheets.Add(
                    //        Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    //}
                    colIndex = 0;
                    rowIndex = 2;
                    break;
                }
                }
            }
        }
Exemple #14
0
        private void ExportCurrentData(ExcelPackage excel,IEnumerable<EDataTable> dsData, ExportStyle style)
        {
            var rowIndex = 3;
            var colIndex = 0;

            foreach (var dtb in dsData)
            {
                AddDataTableToExcel(excel, dtb, style, ref rowIndex, ref colIndex);

                switch (style)
                {
                    case ExportStyle.RowWise:
                        {
                            colIndex = 0;
                            rowIndex += _excelStyle.RowSpaceBetweenTables + 1;
                            break;
                        }
                    case ExportStyle.ColumnWise:
                        {
                            rowIndex = 3;
                            colIndex += _excelStyle.ColumnSpaceBetweenTables;
                            break;
                        }
                    case ExportStyle.SheetWise:
                        {
                            //if (i != dsData.Values.Count - 1)
                            //{
                            //    excel.Worksheets.Add(
                            //        Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                            //}
                            colIndex = 0;
                            rowIndex = 2;
                            break;
                        }
                }
            }
        }
        public static async Task <ExportResult> ExportPngAsync(
            ExportStyle style,
            InstalledFont selectedFont,
            FontVariant selectedVariant,
            Character selectedChar,
            CanvasTextLayoutAnalysis analysis,
            CanvasTypography typography,
            AppSettings settings)
        {
            try
            {
                string name = GetFileName(selectedFont, selectedVariant, selectedChar, "png");
                if (await PickFileAsync(name, "PNG Image", new[] { ".png" }) is StorageFile file)
                {
                    CachedFileManager.DeferUpdates(file);

                    if (analysis.GlyphFormats.Contains(GlyphImageFormat.Png))
                    {
                        IBuffer buffer = GetGlyphBuffer(selectedVariant.FontFace, selectedChar.UnicodeIndex, GlyphImageFormat.Png);
                        await FileIO.WriteBufferAsync(file, buffer);
                    }
                    else
                    {
                        var device   = Utils.CanvasDevice;
                        var localDpi = 96; //Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi;

                        var canvasH = (float)settings.PngSize;
                        var canvasW = (float)settings.PngSize;

                        using var renderTarget = new CanvasRenderTarget(device, canvasW, canvasH, localDpi);
                        using (var ds = renderTarget.CreateDrawingSession())
                        {
                            ds.Clear(Colors.Transparent);
                            var d = settings.PngSize;
                            var r = settings.PngSize / 2;

                            var textColor = style == ExportStyle.Black ? Colors.Black : Colors.White;
                            var fontSize  = (float)d;

                            using CanvasTextLayout layout = new CanvasTextLayout(device, $"{selectedChar.Char}", new CanvasTextFormat
                            {
                                FontSize            = fontSize,
                                FontFamily          = selectedVariant.Source,
                                FontStretch         = selectedVariant.FontFace.Stretch,
                                FontWeight          = selectedVariant.FontFace.Weight,
                                FontStyle           = selectedVariant.FontFace.Style,
                                HorizontalAlignment = CanvasHorizontalAlignment.Center,
                                Options             = style == ExportStyle.ColorGlyph ? CanvasDrawTextOptions.EnableColorFont : CanvasDrawTextOptions.Default
                            }, canvasW, canvasH);

                            if (style == ExportStyle.ColorGlyph)
                            {
                                layout.Options = CanvasDrawTextOptions.EnableColorFont;
                            }

                            layout.SetTypography(0, 1, typography);

                            var    db    = layout.DrawBounds;
                            double scale = Math.Min(1, Math.Min(canvasW / db.Width, canvasH / db.Height));
                            var    x     = -db.Left + ((canvasW - (db.Width * scale)) / 2d);
                            var    y     = -db.Top + ((canvasH - (db.Height * scale)) / 2d);

                            ds.Transform =
                                Matrix3x2.CreateTranslation(new Vector2((float)x, (float)y))
                                * Matrix3x2.CreateScale(new Vector2((float)scale));

                            ds.DrawTextLayout(layout, new Vector2(0), textColor);
                        }

                        using var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite);

                        fileStream.Size = 0;
                        await renderTarget.SaveAsync(fileStream, CanvasBitmapFileFormat.Png, 1f);
                    }

                    await CachedFileManager.CompleteUpdatesAsync(file);

                    return(new ExportResult(true, file));
                }
            }
            catch (Exception ex)
            {
                await SimpleIoc.Default.GetInstance <IDialogService>()
                .ShowMessageBox(ex.Message, Localization.Get("SaveImageError"));
            }

            return(new ExportResult(false, null));
        }
Exemple #16
0
        private void AddDataTableToExcel(ExcelPackage excel, EDataTable table, ExportStyle style, ref int rowIndex, ref int columnIndex)
        {
            if (excel == null) throw new ArgumentNullException("excel");

            var colstart = columnIndex;
            var colbak = colstart;
            if (style == ExportStyle.SheetWise)
            {
                var worksheet = excel.Workbook.Worksheets.Last();
                worksheet.Name = table.TableName;
            }

            foreach (DataColumn col in table.Columns)
            {
                columnIndex += _excelStyle.ColumnSpace;
                var cel = excel.Workbook.Worksheets.Last().Cells[rowIndex, columnIndex];

              //  cel.Style.Font..Color = ColorTranslator.ToOle(_excelStyle.HeaderBackColor);
                cel.Style.Font.Color.SetColor(_excelStyle.HeaderForeColor);
                cel.Style.Font.Name = _excelStyle.FontName;
                cel.Style.Font.Size = _excelStyle.FontSize;
                cel.Style.Font.Italic = _excelStyle.HeaderItalic;
                cel.Style.Font.Bold = _excelStyle.HeaderFontBold;
                cel.Style.Fill.PatternType = ExcelFillStyle.LightGray;
                cel.Style.Fill.BackgroundColor.SetColor(Color.CadetBlue);

               excel.Workbook.Worksheets.Last().Cells[rowIndex, columnIndex].Value = col.ColumnName;
            }
            var colmcount = table.Columns.Count - 1;
            foreach (DataRow row in table.Rows)
            {
                if (ExportRowProgress != null)
                    ExportRowProgress(_eventRow++, _progressRowCount);
                rowIndex += _excelStyle.RowSpace;
                int indexer = 0;

                    foreach (DataColumn col in table.Columns)
                    {

                        colstart += _excelStyle.ColumnSpace;

                        var cel = excel.Workbook.Worksheets.Last().Cells[rowIndex, colstart];
                        if(indexer == colmcount)
                        {
                            var borders = cel.Style.Border;
                            borders.Right.Style = ExcelBorderStyle.Medium;
                            borders.Right.Color.SetColor(Color.Black);

                        }

                        if(col is EDataColumn)
                        {
                            cel.Style.Font.Color.SetColor(Color.Black);
                            cel.Style.Font.Name = _excelStyle.FontName;
                            cel.Style.Font.Size = _excelStyle.FontSize;
                            cel.Style.Font.Italic = _excelStyle.ItemItalic;
                            cel.Style.Font.Bold = true;// _excelStyle.ItemFontBold;
                            cel.Style.Fill.PatternType = ExcelFillStyle.LightGray;
                            cel.Style.Fill.BackgroundColor.SetColor(Color.LightSlateGray);

                        }
                        else
                        {
                        cel.Style.Font.Color.SetColor(_excelStyle.ItemForeColor);
                        cel.Style.Font.Name = _excelStyle.FontName;
                        cel.Style.Font.Size = _excelStyle.FontSize;
                        cel.Style.Font.Italic = _excelStyle.ItemItalic;
                        cel.Style.Font.Bold = _excelStyle.ItemFontBold;

                        }

                        excel.Workbook.Worksheets.Last().Cells[rowIndex, colstart].Value = row[col.ColumnName].ToString();
                        indexer++;
                    }

                colstart = colbak;

            }
        }
Exemple #17
0
        public void ExportDataToExcel(EDataTableDictionary dsData, ExportStyle style, string profileName)
        {
            _eventRow = 1;
            foreach (var item in dsData)
            {
                _progressRowCount += item.Value.Rows.Count;
            }

            string appPath = AppDomain.CurrentDomain.BaseDirectory;
            var    path    = Path.GetFullPath(appPath + @"\" + "DataExportFiles");
            var    iExists = Directory.Exists(path);

            if (!iExists)
            {
                Directory.CreateDirectory(path);
            }

            var fullPath = Path.GetFullPath(path + @"\" + profileName);

            var isExists = Directory.Exists(fullPath);

            if (!isExists)
            {
                Directory.CreateDirectory(fullPath);
            }
            var finko = new FileStream(fullPath + @"\" + profileName + " " + DateTime.Now.Month + "_" + DateTime.Now.Day + " " + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second + "_" + DateTime.Now.Millisecond + ".xlsx",
                                       FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);


            using (var excel = new  ExcelPackage(finko))
            {
                var workbooks = excel.Workbook;
                workbooks.Worksheets.Add("Sheet");
                var myDataList = new List <EDataTable>();
                var myNameList = new List <string>();


                #region SnapShotExport

                var snapshots     = from items in dsData where items.Value.IsSnapShotTable select items;
                var keyValuePairs = snapshots as List <KeyValuePair <string, EDataTable> > ?? snapshots.ToList();


                //export snapsots
                foreach (var items in keyValuePairs)
                {
                    myDataList.Clear();
                    myNameList.Clear();
                    myDataList.Add(items.Value);
                    myNameList.Add(items.Key);
                    _tableCounter++;
                    var items1 = items;
                    var list   = dsData.Where(tbl => tbl.Value.SnapshotRelationID == items1.Value.SnapShotID);
                    foreach (var eDataTable in list)
                    {
                        myDataList.Add(eDataTable.Value);
                        myNameList.Add(eDataTable.Key);
                        _tableCounter++;
                    }

                    ExportCurrentData(excel, myDataList, style); //export the queries
                    FormatExcelSheet(excel, myDataList, myNameList);


                    excel.Workbook.Worksheets.Add("Sheet");
                }



                #endregion

                #region TimeSliceExport

                var timeslices = from items in dsData where items.Value.IsTimeSliceTable select items;

                var timslicevalues = timeslices as List <KeyValuePair <string, EDataTable> > ?? timeslices.ToList();

                foreach (var items in timslicevalues)
                {
                    myDataList.Clear();
                    myNameList.Clear();
                    myDataList.Add(items.Value);
                    myNameList.Add(items.Key);
                    _tableCounter++;
                    var items1 = items;
                    var list   = dsData.Where(tbl => tbl.Value.TimeSliceRelationID == items1.Value.TimeSliceID);
                    foreach (var eDataTable in list)
                    {
                        myDataList.Add(eDataTable.Value);
                        myNameList.Add(eDataTable.Key);
                        _tableCounter++;
                    }

                    ExportCurrentData(excel, myDataList, style); //export the queries
                    FormatExcelSheet(excel, myDataList, myNameList);

                    if (_tableCounter < dsData.Count())
                    {
                        excel.Workbook.Worksheets.Add("Sheet");
                    }
                }
                #endregion
                excel.Save();
                excel.Dispose();
            }
        }
Exemple #18
0
        private void AddDataTableToExcel(ExcelPackage excel, EDataTable table, ExportStyle style, ref int rowIndex, ref int columnIndex)
        {
            if (excel == null)
            {
                throw new ArgumentNullException("excel");
            }

            var colstart = columnIndex;
            var colbak   = colstart;

            if (style == ExportStyle.SheetWise)
            {
                var worksheet = excel.Workbook.Worksheets.Last();
                worksheet.Name = table.TableName;
            }

            foreach (DataColumn col in table.Columns)
            {
                columnIndex += _excelStyle.ColumnSpace;
                var cel = excel.Workbook.Worksheets.Last().Cells[rowIndex, columnIndex];

                //  cel.Style.Font..Color = ColorTranslator.ToOle(_excelStyle.HeaderBackColor);
                cel.Style.Font.Color.SetColor(_excelStyle.HeaderForeColor);
                cel.Style.Font.Name        = _excelStyle.FontName;
                cel.Style.Font.Size        = _excelStyle.FontSize;
                cel.Style.Font.Italic      = _excelStyle.HeaderItalic;
                cel.Style.Font.Bold        = _excelStyle.HeaderFontBold;
                cel.Style.Fill.PatternType = ExcelFillStyle.LightGray;
                cel.Style.Fill.BackgroundColor.SetColor(Color.CadetBlue);

                excel.Workbook.Worksheets.Last().Cells[rowIndex, columnIndex].Value = col.ColumnName;
            }
            var colmcount = table.Columns.Count - 1;

            foreach (DataRow row in table.Rows)
            {
                if (ExportRowProgress != null)
                {
                    ExportRowProgress(_eventRow++, _progressRowCount);
                }
                rowIndex += _excelStyle.RowSpace;
                int indexer = 0;

                foreach (DataColumn col in table.Columns)
                {
                    colstart += _excelStyle.ColumnSpace;

                    var cel = excel.Workbook.Worksheets.Last().Cells[rowIndex, colstart];
                    if (indexer == colmcount)
                    {
                        var borders = cel.Style.Border;
                        borders.Right.Style = ExcelBorderStyle.Medium;
                        borders.Right.Color.SetColor(Color.Black);
                    }

                    if (col is EDataColumn)
                    {
                        cel.Style.Font.Color.SetColor(Color.Black);
                        cel.Style.Font.Name        = _excelStyle.FontName;
                        cel.Style.Font.Size        = _excelStyle.FontSize;
                        cel.Style.Font.Italic      = _excelStyle.ItemItalic;
                        cel.Style.Font.Bold        = true;// _excelStyle.ItemFontBold;
                        cel.Style.Fill.PatternType = ExcelFillStyle.LightGray;
                        cel.Style.Fill.BackgroundColor.SetColor(Color.LightSlateGray);
                    }
                    else
                    {
                        cel.Style.Font.Color.SetColor(_excelStyle.ItemForeColor);
                        cel.Style.Font.Name   = _excelStyle.FontName;
                        cel.Style.Font.Size   = _excelStyle.FontSize;
                        cel.Style.Font.Italic = _excelStyle.ItemItalic;
                        cel.Style.Font.Bold   = _excelStyle.ItemFontBold;
                    }

                    excel.Workbook.Worksheets.Last().Cells[rowIndex, colstart].Value = row[col.ColumnName].ToString();
                    indexer++;
                }

                colstart = colbak;
            }
        }
Exemple #19
0
 /// <remarks/>
 public void GetComboListByNameAsync(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string comboName, object[] args) {
     this.GetComboListByNameAsync(userName, password, exportStyle, applicationURL, gridURL, comboName, args, null);
 }
        public static async Task ExportSvgAsync(
            ExportStyle style,
            InstalledFont selectedFont,
            FontVariant selectedVariant,
            Character selectedChar,
            CanvasTypography typography)
        {
            try
            {
                string name = GetFileName(selectedFont, selectedVariant, selectedChar, "svg");
                if (await PickFileAsync(name, "SVG", new[] { ".svg" }) is StorageFile file)
                {
                    CachedFileManager.DeferUpdates(file);
                    var device = Utils.CanvasDevice;

                    var textColor = style == ExportStyle.Black ? Colors.Black : Colors.White;

                    /* SVG Exports render at fixed size - but a) they're vectors, and b) they're
                     * inside an auto-scaling viewport. So rendersize is *largely* pointless */
                    float canvasH = 1024f, canvasW = 1024f, fontSize = 1024f;

                    using (CanvasTextLayout layout = new CanvasTextLayout(device, $"{selectedChar.Char}", new CanvasTextFormat
                    {
                        FontSize = fontSize,
                        FontFamily = selectedVariant.Source,
                        FontStretch = selectedVariant.FontFace.Stretch,
                        FontWeight = selectedVariant.FontFace.Weight,
                        FontStyle = selectedVariant.FontFace.Style,
                        HorizontalAlignment = CanvasHorizontalAlignment.Center
                    }, canvasW, canvasH))
                    {
                        layout.SetTypography(0, 1, typography);

                        using (CanvasGeometry temp = CanvasGeometry.CreateText(layout))
                        {
                            var    b     = temp.ComputeBounds();
                            double scale = Math.Min(1, Math.Min(canvasW / b.Width, canvasH / b.Height));

                            Matrix3x2 transform =
                                Matrix3x2.CreateTranslation(new Vector2((float)-b.Left, (float)-b.Top))
                                * Matrix3x2.CreateScale(new Vector2((float)scale));

                            using (CanvasGeometry geom = temp.Transform(transform))
                            {
                                /*
                                 * Unfortunately this only constructs a monochrome path, if we want color
                                 * Win2D does not yet expose the neccessary API's to get the individual glyph
                                 * layers that make up a colour glyph.
                                 *
                                 * We'll need to handle this in C++/CX if we want to do this at some point.
                                 */

                                SVGPathReciever rc = new SVGPathReciever();
                                geom.SendPathTo(rc);

                                Rect bounds = geom.ComputeBounds();
                                using (CanvasSvgDocument document = Utils.GenerateSvgDocument(device, bounds.Width, bounds.Height, rc))
                                {
                                    ((CanvasSvgNamedElement)document.Root.FirstChild).SetColorAttribute("fill", textColor);
                                    await Utils.WriteSvgAsync(document, file);
                                }
                            }
                        }
                    }

                    await CachedFileManager.CompleteUpdatesAsync(file);
                }
            }
            catch (Exception ex)
            {
                await SimpleIoc.Default.GetInstance <IDialogService>()
                .ShowMessageBox(ex.Message, Localization.Get("SaveImageError"));
            }
        }
Exemple #21
0
        public void ExportDataToExcel(EDataTableDictionary dsData, ExportStyle style,string profileName )
        {
            _eventRow = 1;
            foreach(var item in dsData)
                {
                   _progressRowCount += item.Value.Rows.Count;
                }

            string appPath = AppDomain.CurrentDomain.BaseDirectory;
            var path = Path.GetFullPath(appPath + @"\" + "DataExportFiles");
            var iExists = Directory.Exists(path);

            if (!iExists)
                Directory.CreateDirectory(path);

            var fullPath = Path.GetFullPath(path + @"\" + profileName);

            var isExists = Directory.Exists(fullPath);

            if (!isExists)
                Directory.CreateDirectory(fullPath);
            var finko = new FileStream(fullPath + @"\" + profileName + " " + DateTime.Now.Month + "_" + DateTime.Now.Day + " " + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second + "_" + DateTime.Now.Millisecond + ".xlsx",
               FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);

            using (var excel = new  ExcelPackage(finko))
            {

                var workbooks = excel.Workbook;
                workbooks.Worksheets.Add("Sheet");
                var myDataList = new List<EDataTable>();
                var myNameList = new List<string>();

                #region SnapShotExport

                var snapshots = from items in dsData where items.Value.IsSnapShotTable select items;
                var keyValuePairs = snapshots as List<KeyValuePair<string, EDataTable>> ?? snapshots.ToList();

                //export snapsots
                foreach (var items in keyValuePairs)
                {
                    myDataList.Clear();
                    myNameList.Clear();
                    myDataList.Add(items.Value);
                    myNameList.Add(items.Key);
                    _tableCounter++;
                    var items1 = items;
                    var list = dsData.Where(tbl => tbl.Value.SnapshotRelationID == items1.Value.SnapShotID);
                    foreach (var eDataTable in list)
                    {
                        myDataList.Add(eDataTable.Value);
                        myNameList.Add(eDataTable.Key);
                        _tableCounter++;
                    }

                    ExportCurrentData(excel, myDataList, style); //export the queries
                    FormatExcelSheet(excel, myDataList, myNameList);

                    excel.Workbook.Worksheets.Add("Sheet");

                }

                #endregion

                #region TimeSliceExport

                var timeslices = from items in dsData where items.Value.IsTimeSliceTable select items;

                var timslicevalues = timeslices as List<KeyValuePair<string, EDataTable>> ?? timeslices.ToList();

                foreach (var items in timslicevalues)
                {
                    myDataList.Clear();
                    myNameList.Clear();
                    myDataList.Add(items.Value);
                    myNameList.Add(items.Key);
                    _tableCounter++;
                    var items1 = items;
                    var list = dsData.Where(tbl => tbl.Value.TimeSliceRelationID == items1.Value.TimeSliceID);
                    foreach (var eDataTable in list)
                    {
                        myDataList.Add(eDataTable.Value);
                        myNameList.Add(eDataTable.Key);
                        _tableCounter++;

                    }

                    ExportCurrentData(excel, myDataList, style); //export the queries
                    FormatExcelSheet(excel, myDataList, myNameList);

                    if (_tableCounter < dsData.Count())
                        excel.Workbook.Worksheets.Add("Sheet");

                }
                #endregion
                excel.Save();
                excel.Dispose();

            }
        }
Exemple #22
0
 /// <remarks/>
 public void RunActionByNameAsync(string userName, string password, ExportStyle exportStyle, string applicationURL, string gridURL, string actionName, object[] args) {
     this.RunActionByNameAsync(userName, password, exportStyle, applicationURL, gridURL, actionName, args, null);
 }
        public static async Task <ExportResult> ExportSvgAsync(
            ExportStyle style,
            InstalledFont selectedFont,
            FontVariant selectedVariant,
            Character selectedChar,
            CanvasTextLayoutAnalysis analysis,
            CanvasTypography typography)
        {
            try
            {
                string name = GetFileName(selectedFont, selectedVariant, selectedChar, "svg");
                if (await PickFileAsync(name, "SVG", new[] { ".svg" }) is StorageFile file)
                {
                    CachedFileManager.DeferUpdates(file);

                    CanvasDevice device    = Utils.CanvasDevice;
                    Color        textColor = style == ExportStyle.Black ? Colors.Black : Colors.White;


                    // If COLR format (e.g. Segoe UI Emoji), we have special export path.
                    if (style == ExportStyle.ColorGlyph && analysis.HasColorGlyphs && !analysis.GlyphFormats.Contains(GlyphImageFormat.Svg))
                    {
                        NativeInterop interop = Utils.GetInterop();
                        List <string> paths   = new List <string>();
                        Rect          bounds  = Rect.Empty;

                        foreach (var thing in analysis.Indicies)
                        {
                            var path = interop.GetPathDatas(selectedVariant.FontFace, thing.ToArray()).First();
                            paths.Add(path.Path);

                            if (!path.Bounds.IsEmpty)
                            {
                                var left   = Math.Min(bounds.Left, path.Bounds.Left);
                                var top    = Math.Min(bounds.Top, path.Bounds.Top);
                                var right  = Math.Max(bounds.Right, path.Bounds.Right);
                                var bottom = Math.Max(bounds.Bottom, path.Bounds.Bottom);
                                bounds = new Rect(
                                    left,
                                    top,
                                    right - left,
                                    bottom - top);
                            }
                        }

                        using (CanvasSvgDocument document = Utils.GenerateSvgDocument(device, bounds, paths, analysis.Colors, invertBounds: false))
                        {
                            await Utils.WriteSvgAsync(document, file);
                        }

                        return(new ExportResult(true, file));
                    }



                    var data = GetGeometry(1024, selectedVariant, selectedChar, analysis, typography);
                    async Task SaveMonochromeAsync()
                    {
                        using CanvasSvgDocument document = Utils.GenerateSvgDocument(device, data.Bounds, data.Path, textColor);
                        await Utils.WriteSvgAsync(document, file);
                    }

                    // If the font uses SVG glyphs, we can extract the raw SVG from the font file
                    if (analysis.GlyphFormats.Contains(GlyphImageFormat.Svg))
                    {
                        string  str = null;
                        IBuffer b   = GetGlyphBuffer(selectedVariant.FontFace, selectedChar.UnicodeIndex, GlyphImageFormat.Svg);
                        if (b.Length > 2 && b.GetByte(0) == 31 && b.GetByte(1) == 139)
                        {
                            using var stream = b.AsStream();
                            using var gzip   = new GZipStream(stream, CompressionMode.Decompress);
                            using var reader = new StreamReader(gzip);
                            str = reader.ReadToEnd();
                        }
                        else
                        {
                            using var dataReader       = DataReader.FromBuffer(b);
                            dataReader.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8;
                            str = dataReader.ReadString(b.Length);
                        }

                        if (str.StartsWith("<?xml"))
                        {
                            str = str.Remove(0, str.IndexOf(">") + 1);
                        }

                        str = str.TrimStart();

                        try
                        {
                            using (CanvasSvgDocument document = CanvasSvgDocument.LoadFromXml(Utils.CanvasDevice, str))
                            {
                                // We need to transform the SVG to fit within the default document bounds, as characters
                                // are based *above* the base origin of (0,0) as (0,0) is the Baseline (bottom left) position for a character,
                                // so by default a will appear out of bounds of the default SVG viewport (towards top left).

                                //if (!document.Root.IsAttributeSpecified("viewBox")) // Specified viewbox requires baseline transform?
                                {
                                    // We'll regroup all the elements inside a "g" / group tag,
                                    // and apply a transform to the "g" tag to try and put in
                                    // in the correct place. There's probably a more accurate way
                                    // to do this by directly setting the root viewBox, if anyone
                                    // can find the correct calculation...

                                    List <ICanvasSvgElement> elements = new List <ICanvasSvgElement>();

                                    double minTop    = 0;
                                    double minLeft   = double.MaxValue;
                                    double maxWidth  = double.MinValue;
                                    double maxHeight = double.MinValue;

                                    void ProcessChildren(CanvasSvgNamedElement root)
                                    {
                                        CanvasSvgNamedElement ele = root.FirstChild as CanvasSvgNamedElement;

                                        while (true)
                                        {
                                            CanvasSvgNamedElement next = root.GetNextSibling(ele) as CanvasSvgNamedElement;
                                            if (ele.Tag == "g")
                                            {
                                                ProcessChildren(ele);
                                            }
                                            else if (ele.Tag == "path")
                                            {
                                                // Create a XAML geometry to try and find the bounds of each character
                                                // Probably more efficient to do in Win2D, but far less code to do with XAML.
                                                Geometry gm = XamlBindingHelper.ConvertValue(typeof(Geometry), ele.GetStringAttribute("d")) as Geometry;
                                                minTop    = Math.Min(minTop, gm.Bounds.Top);
                                                minLeft   = Math.Min(minLeft, gm.Bounds.Left);
                                                maxWidth  = Math.Max(maxWidth, gm.Bounds.Width);
                                                maxHeight = Math.Max(maxHeight, gm.Bounds.Height);
                                            }
                                            ele = next;
                                            if (ele == null)
                                            {
                                                break;
                                            }
                                        }
                                    }

                                    ProcessChildren(document.Root);

                                    double top  = minTop < 0 ? minTop : 0;
                                    double left = minLeft;
                                    document.Root.SetRectangleAttribute("viewBox", new Rect(left, top, data.Bounds.Width, data.Bounds.Height));
                                }

                                await Utils.WriteSvgAsync(document, file);
                            }
                        }
                        catch
                        {
                            // Certain fonts seem to have their SVG glyphs encoded with... I don't even know what encoding.
                            // for example: https://github.com/adobe-fonts/emojione-color
                            // In these cases, fallback to monochrome black
                            await SaveMonochromeAsync();
                        }
                    }
                    else
                    {
                        await SaveMonochromeAsync();
                    }

                    await CachedFileManager.CompleteUpdatesAsync(file);

                    return(new ExportResult(true, file));
                }
            }
            catch (Exception ex)
            {
                await SimpleIoc.Default.GetInstance <IDialogService>()
                .ShowMessageBox(ex.Message, Localization.Get("SaveImageError"));
            }

            return(new ExportResult(false, null));
        }
Exemple #24
0
        public static string GetExtention(ExportStyle style)
        {
            var extention = (style != ExportStyle.Unspecified) ? style : ExportStyle.Jpg;

            return(ExtentionDictionary[extention]);
        }