Exemplo n.º 1
0
        private async void BtnExport_Click(object sender, EventArgs e)
        {
            BtnSelect.Enabled = false;
            cancelToken       = new CancellationTokenSource();
            Directory.CreateDirectory(sheetsDirectoryPath);
            ShowLabelProgress();

            Bitmap resized = DearVisualStudio.ResizeThePicture(pictureBitmap, avaliableSize);

            CheckExistingExcellProcesses();


            await Task.Factory.StartNew(() => ExportPicture(resized), cancelToken.Token);

            AskForOpeningDirectory();
            BtnSelect.Enabled = true;
        }
Exemplo n.º 2
0
        private void ConvertBitmapToExcelSheet(Bitmap resized)
        {
            for (int column = 0; column < resized.Width; column++)
            {
                string letter = DearVisualStudio.GiveMeLetterForThisColumn(column);
                UpdateLabelProgress(column, resized.Width);

                for (int row = 0; row < resized.Height; row++)
                {
                    dynamic cell     = excelSheet.Cells[row + 1, letter];
                    dynamic interior = cell.Interior;
                    interior.Color = ColorTranslator.ToOle(resized.GetPixel(column, row));

                    cancelToken.Token.ThrowIfCancellationRequested();
                }
            }
        }