public void printXLS(string filename, List<List<int>> allIterations, List<string> files)
        {
            WorkBook workbook = WorkBook.Load(filename);
            WorkSheet sheet = workbook.DefaultWorkSheet;

            for (int i = 0; i < allIterations.Count; i++)
            {
                sheet.SetCellValue(0, i, files[i]);
                for (int j = 1; j < allIterations[i].Count + 1; j++)
                {
                    sheet.SetCellValue(j, i, allIterations[i][j - 1]);
                }
            }
            //Save Changes
            workbook.SaveAs(filename);

            /*
            //iterate over range of cells
            foreach (var cell in range)
            {
                Console.WriteLine("Cell {0} has value '{1}", cell.RowIndex, cell.Value);
                if (cell.IsNumeric)
                {
                    //Get decimal value to avoid floating numbers precision issue
                    total += cell.DecimalValue;
                }
            }
            //check formula evaluation
            if (sheet["A11"].DecimalValue == total)
            {
                Console.WriteLine("Basic Test Passed");
            }
            */
        }
Example #2
0
        //Upisuje u excel tabelu podatak
        public static bool SetData(int row, string data)
        {
            if (ws == null)
            {
                Console.WriteLine("Greska u postavljanju podataka");
                return(false);
            }

            ws.SetCellValue(row, ws.Rows[row].Columns.Count, data);
            wb.SaveAs(Constants.XLPath);
            return(true);
        }
        public void PrintDeleted(string filename, List<List<List<int>>> matrices, List<string> files)
        {
            WorkBook workbook = WorkBook.Load(filename);
            WorkSheet sheet = workbook.DefaultWorkSheet;

            for (int i = 0; i < matrices.Count; i++)
            {
                int x = (int)Math.Floor((decimal)i / 2);
                sheet.SetCellValue(0, matrices[0].Count * i, files[x]);
                for (int j = 0; j < matrices[0].Count; j++)
                {
                    for (int k = 1; k < matrices[i][j].Count + 1; k++)
                    {
                        sheet.SetCellValue(k, j + (matrices[0].Count * i), matrices[i][j][k - 1]);
                    }
                }
                Console.WriteLine("Printed" + (i + 1) + "/" + matrices.Count);
            }
            //Save Changes
            workbook.SaveAs(filename);
        }
        public void PrintMatrices(string filename, List<List<List<int>>> matrices, List<string> files)
        {
            WorkBook workbook = WorkBook.Load(filename);
            WorkSheet sheet = workbook.DefaultWorkSheet;

            for (int i = 0; i < matrices.Count; i++)
            {
                sheet.SetCellValue(i * matrices[0].Count, 0, files[i]);
                for (int j = 0; j < matrices[0].Count; j++)
                {
                    for (int k = 1; k < matrices[i][j].Count + 1; k++)
                    {
                        sheet.SetCellValue(k + (matrices[0].Count * i) - 1, j + 1, matrices[i][j][k - 1]);
                    }
                }
                Console.WriteLine("Printed" + (i + 1) + "/" + matrices.Count);
            }

            //Save Changes
            workbook.SaveAs(filename);
        }
Example #5
0
        //Upisuje u excel tabelu podatak
        public static bool SetData(int row, string data) //u kom redu upisuje
        {
            if (ws == null)                              //da li je ucitan ws
            {
                Console.WriteLine("Greska u postavljanju podataka");
                return(false);
            }

            ws.SetCellValue(row, ws.Rows[row].Columns.Count, data); //ako je ws ucitan, dodajemo range koji red, koja kolona, data
            wb.SaveAs(Constants.Excel_Path);
            return(true);
        }
Example #6
0
        static void FillSheetFromDb()
        {
            testDBEntities dbContext = new testDBEntities();

            WorkBook workbook = WorkBook.Load($@"{Directory.GetCurrentDirectory()}\Files\testFile.xlsx");

            WorkSheet sheet = workbook.CreateWorkSheet("FromDb");

            List <Country> countryList = dbContext.Countries.ToList();

            sheet.SetCellValue(0, 0, "Id");
            sheet.SetCellValue(0, 1, "Country Name");
            int row = 1;

            foreach (var item in countryList)
            {
                sheet.SetCellValue(row, 0, item.id);
                sheet.SetCellValue(row, 1, item.CountryName);
                row++;
            }
            workbook.SaveAs("FilledFile.xlsx");
        }
Example #7
0
 public void writeResult(int startRow, PrettyResult prettyResult, OutputTheme theme)
 {
     for (int i = 0; i < prettyResult.resultTable.GetLength(0); i++)
     {
         for (int j = 0; j < prettyResult.resultTable.GetLength(1); j++)
         {
             PrettyResultCell prettyCell = prettyResult.resultTable[i, j];
             if (prettyCell != null)
             {
                 workSheet.SetCellValue(startRow + i, j, prettyCell.value);
                 workSheet.GetCellAt(startRow + i, j).Style.SetBackgroundColor(theme.getColor(prettyResult.resultTable[i, j].type));
             }
         }
     }
     wb.SaveAs(filePath);
 }