private void StudentsListView_Load(object sender, EventArgs e)
 {
     try
     {
         using (Stream input = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Spreadsheets/students-grades.xlsx"), FileMode.Open))
         {
             this.radSpreadsheet1.Workbook = _formatProvider.Import(input);
         }
     }
     catch
     {
         ImportFile();
     }
 }
        public async void ViewFormattedDocument(object parameter)
        {
            IWorkbookFormatProvider provider = new XlsxFormatProvider();
            Workbook workbook;

            try
            {
                Assembly assembly = typeof(ConditionalFormattingViewModel).Assembly;
                string   fileName = assembly.GetManifestResourceNames().First(n => n.Contains("SpreadProcessingDocument2.xlsx"));

                using (Stream stream = assembly.GetManifestResourceStream(fileName))
                {
                    workbook = provider.Import(stream);
                }
                this.AddRules(workbook);

                Stream mystream = await OpenStreamAsync(workbook);

                using (mystream)
                {
                    IFileViewerService fileViewerService = DependencyService.Get <IFileViewerService>();
                    await fileViewerService.View(mystream, fileName);
                }
            }
            catch
            {
                IMessageService messageService = DependencyService.Get <IMessageService>();
                await messageService.ShowMessage("An error occured", "An error occured, please try again.");
            }
        }
예제 #3
0
 void LoadResourceFile(string filePath)
 {
     XlsxFormatProvider formatProvider = new XlsxFormatProvider();
     using (var stream = ResourceHelper.GetResourceStream(filePath))
     {
         this.radSpreadsheet.Workbook = formatProvider.Import(stream);
     }
 }
예제 #4
0
        void LoadResourceFile(string filePath)
        {
            XlsxFormatProvider formatProvider = new XlsxFormatProvider();

            using (var stream = ResourceHelper.GetResourceStream(filePath))
            {
                this.radSpreadsheet.Workbook = formatProvider.Import(stream);
            }
        }
예제 #5
0
        private static Workbook ImportWorkbook()
        {
            Assembly assembly = typeof(FindAndReplaceViewModel).Assembly;
            string   fileName = assembly.GetManifestResourceNames().First(n => n.Contains("SpreadProcessingDocument1.xlsx"));

            using (Stream stream = assembly.GetManifestResourceStream(fileName))
            {
                IWorkbookFormatProvider provider = new XlsxFormatProvider();
                Workbook workbook = provider.Import(stream);
                return(workbook);
            }
        }
 private void RadSpreadsheet_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         using (Stream input = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Spreadsheets/students-grades.xlsx"), FileMode.Open))
         {
             this.radSpreadsheet.Workbook = _formatProvider.Import(input);
         }
     }
     catch
     {
         MessageBox.Show("Student grades spreadsheet not found!");
     }
 }
예제 #7
0
        private void OpenFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog     ofd            = new OpenFileDialog();
            XlsxFormatProvider formatProvider = new XlsxFormatProvider();

            ofd.Filter = "Excel Workbook (*xlsx)|*.xlsx|All Files (*.*)|*.*";

            if (ofd.ShowDialog() == true)
            {
                using (Stream input = ofd.OpenRead())
                {
                    this.radSpreadsheet.Workbook = formatProvider.Import(input);
                }
            }
        }
예제 #8
0
        public void ImportWorkbookFromXlsx()
        {
            #region radspreadprocessing-working-with-workbooks-create-open-and-save-workbooks_1
            const string FilePath  = @"http://localhost:54352/Resourses/SampleFile.xlsx";
            WebClient    webClient = new WebClient();

            webClient.OpenReadCompleted += (sender, eventArgs) =>
            {
                XlsxFormatProvider formatProvider = new XlsxFormatProvider();
                Workbook           workbook       = formatProvider.Import(eventArgs.Result);
            };

            webClient.OpenReadAsync(new Uri(FilePath));
            #endregion
        }
        private void gridFacturas_CellDoubleClick(object sender, GridViewCellEventArgs e)
        {
            try
            {
                Limpiar();
                btnActualizar.Visible = true;
                btnInsertar.Visible   = false;

                txtIdFac.Text      = gridFacturas.CurrentRow.Cells["FacturaId"].Value?.ToString();
                txtEstado.Text     = gridFacturas.CurrentRow.Cells["Estado"].Value?.ToString();
                txtNumFactura.Text = gridFacturas.CurrentRow.Cells["NumeroFactura"].Value?.ToString();
                numFacAnt          = gridFacturas.CurrentRow.Cells["NumeroFactura"].Value?.ToString();
                dateFactura.Value  = Convert.ToDateTime(gridFacturas.CurrentRow.Cells["FechaEmision"].Value?.ToString());
                txtRutaFac.Text    = gridFacturas.CurrentRow.Cells["ArchivoFactura"].Value?.ToString();
                rutaFacAnt         = gridFacturas.CurrentRow.Cells["ArchivoFactura"].Value?.ToString();

                var rutaFile = Path.Combine(directorio, txtRutaFac.Text);

                if (Path.GetExtension(rutaFile) == ".xml")
                {
                    radSpreadsheet1.Visible = false;
                    webBrowser1.Visible     = true;

                    webBrowser1.Navigate(rutaFile);
                }
                else if (Path.GetExtension(rutaFile) == ".xlsx")
                {
                    radSpreadsheet1.Visible = true;
                    webBrowser1.Visible     = false;

                    var formatProvider = new XlsxFormatProvider();

                    using (FileStream input = new FileStream(rutaFile, FileMode.Open))
                    {
                        radSpreadsheet1.Workbook = formatProvider.Import(input);
                    }
                }

                tabForm.SelectedTab = tabManteniminento;
            }
            catch
            {
                MessageBox.Show("No hay ningún registro que selecionar");
            }
        }
예제 #10
0
        private async Task <Workbook> OpenExcelFile()
        {
            IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();
            Workbook wb;

            try
            {
                using (FileStream input = new FileStream(fileInfo.FullName, FileMode.Open))
                {
                    wb = formatProvider.Import(input);
                    return(wb);
                }
            }
            catch (Exception)
            {
                throw new Exception($"Die Datei {fileInfo.Name} kann nicht geöffnet werden. Sie wird möglicherweise von einem anderen Prozess benutzt. ");
            }
        }
예제 #11
0
        private void ImportSpreadsheet()
        {
            #region radspreadprocessing-formats-and-conversion-xlsx-xlsxformatprovider_0
            string fileName = "SampleFile.xlsx";
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException(String.Format("File {0} was not found!", fileName));
            }

            Workbook workbook;
            IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();

            using (FileStream input = new FileStream(fileName, FileMode.Open))
            {
                workbook = formatProvider.Import(input);
            }
            #endregion
        }
예제 #12
0
        private void ImportWorkbookFromXlsxUsingOpenFileDialog()
        {
            #region radspreadsheet-model-import-export-xlsxformatprovider-silverlight_1
            Workbook workbook;

            OpenFileDialog     openFileDialog = new OpenFileDialog();
            XlsxFormatProvider formatProvider = new XlsxFormatProvider();
            openFileDialog.Filter = "Excel Workbook (*.xlsx)|*.xlsx|All Files (*.*)|*.*";

            if (openFileDialog.ShowDialog() == true)
            {
                using (Stream input = openFileDialog.File.OpenRead())
                {
                    workbook = formatProvider.Import(input);
                }
            }
            #endregion
        }
        private void btnCargarFac_Click(object sender, EventArgs e)
        {
            try
            {
                openFileDialog1.FileName = "";

                openFileDialog1.Filter = "Archivos Excel o Xml (*.xlsx, *.xls, *.xml)|*.xlsx;*.xls;*.xml";

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (Path.GetExtension(openFileDialog1.FileName) == ".xlsx" || Path.GetExtension(openFileDialog1.FileName) == ".xls")
                    {
                        radSpreadsheet1.Visible = true;
                        webBrowser1.Visible     = false;

                        var formatProvider = new XlsxFormatProvider();

                        using (FileStream input = new FileStream(openFileDialog1.FileName, FileMode.Open))
                        {
                            radSpreadsheet1.Workbook = formatProvider.Import(input);
                        }

                        txtRutaFac.Text = Path.GetFileName(openFileDialog1.FileName);

                        this.RutaOrigen = openFileDialog1.FileName;
                    }
                    else if (Path.GetExtension(openFileDialog1.FileName) == ".xml")
                    {
                        radSpreadsheet1.Visible = false;
                        webBrowser1.Visible     = true;

                        webBrowser1.Navigate(openFileDialog1.FileName);

                        txtRutaFac.Text = Path.GetFileName(openFileDialog1.FileName);

                        this.RutaOrigen = openFileDialog1.FileName;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #14
0
        private Workbook LoadWorkbook()
        {
            Workbook result = null;

            try
            {
                XlsxFormatProvider formatProvider = new XlsxFormatProvider();

                using (Stream stream = ResourceHelper.GetResourceStream(ResourceFilePath))
                {
                    result = formatProvider.Import(stream);
                }
            }
            catch
            {
                return(null);
            }

            return(result);
        }
예제 #15
0
        private Workbook LoadWorkbook()
        {
            Workbook result = null;

            try
            {
                XlsxFormatProvider formatProvider = new XlsxFormatProvider();

                using (Stream stream = ResourceHelper.GetResourceStream(ResourceFilePath))
                {
                    result = formatProvider.Import(stream);
                }
            }
            catch
            {
                return null;
            }

            return result;
        }
예제 #16
0
        public void GettingStarted()
        {
            #region radspreadprocessing-getting-started_0
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();
            #endregion

            #region radspreadprocessing-getting-started_1
            CellSelection selection = worksheet.Cells[1, 1]; //B2 cell
            selection.SetValue("Hello RadSpreadProcessing");
            #endregion

            #region radspreadprocessing-getting-started_2
            string fileName = "Hello.xlsx";
            IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();

            using (FileStream input = new FileStream(fileName, FileMode.Open))
            {
                workbook = formatProvider.Import(input);
            }
            #endregion
        }
예제 #17
0
파일: DocViewerVM.cs 프로젝트: unicloud/FRP
 /// <summary>
 ///     展示从本地添加的文档
 ///     <remarks>
 ///         需要将文档相关内容赋给本地的_currentDocument。
 ///     </remarks>
 /// </summary>
 /// <param name="fi">文件</param>
 private void ViewDocument(FileInfo fi)
 {
     var extension = fi.Extension.ToLower();
     var length = (int) fi.Length;
     var fs = fi.OpenRead();
     _content = new byte[length];
     using (fs)
     {
         fs.Read(_content, 0, length);
     }
     switch (extension.ToLower())
     {
         case ".xlsx":
             PDFVisibility = Visibility.Collapsed;
             WordVisibility = Visibility.Collapsed;
             ExcelVisibility = Visibility.Visible;
             IWorkbookFormatProvider provider = new XlsxFormatProvider();
             ExcelContent = provider.Import(new MemoryStream(_content));
             break;
         case ".docx":
             PDFVisibility = Visibility.Collapsed;
             ExcelVisibility = Visibility.Collapsed;
             WordVisibility = Visibility.Visible;
             WordContent = _content;
             break;
         case ".pdf":
             WordVisibility = Visibility.Collapsed;
             ExcelVisibility = Visibility.Collapsed;
             PDFVisibility = Visibility.Visible;
             PDFContent = new MemoryStream(_content);
             break;
         default:
             MessageAlert("不是合法文档!");
             break;
     }
     Title = fi.Name;
     _addedDocument = new DocumentDTO
     {
         DocumentId = Guid.NewGuid(),
         Name = fi.Name,
         Extension = extension,
         FileStorage = _content
     };
 }
예제 #18
0
파일: DocViewerVM.cs 프로젝트: unicloud/FRP
 /// <summary>
 ///     展示从服务端获取的文档
 /// </summary>
 /// <param name="doc">获取的文档</param>
 private void ViewDocument(DocumentDTO doc)
 {
     var extension = doc.Extension;
     _content = doc.FileStorage;
     switch (extension)
     {
         case ".xlsx":
             PDFVisibility = Visibility.Collapsed;
             WordVisibility = Visibility.Collapsed;
             ExcelVisibility = Visibility.Visible;
             IWorkbookFormatProvider provider = new XlsxFormatProvider();
             ExcelContent = provider.Import(new MemoryStream(_content));
             break;
         case ".docx":
             PDFVisibility = Visibility.Collapsed;
             ExcelVisibility = Visibility.Collapsed;
             WordVisibility = Visibility.Visible;
             WordContent = _content;
             break;
         case ".pdf":
             WordVisibility = Visibility.Collapsed;
             ExcelVisibility = Visibility.Collapsed;
             PDFVisibility = Visibility.Visible;
             PDFContent = new MemoryStream(_content);
             break;
         default:
             MessageAlert("不是合法的文档!");
             break;
     }
     Title = doc.Name;
 }
예제 #19
0
        private void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            XlsxFormatProvider formatProvider = new XlsxFormatProvider();

            Workbook workbook = formatProvider.Import(e.Result);
        }