Как здесь вывести гистограмму через excel?
Суть программы: это шифр табличной перестановки, программа меняет строки и столбцы местами, выводит количество букв в txt файле и заносит количество букв в таблицу excel. Как мне вывести гистограмму из количества этих самых букв?
using System;
using Excel = Microsoft.Office.Interop.Excel;
public class Program
{
static void poisk(string stroka, int f)
{
// Создаём экземпляр нашего приложения
Excel.Application excelApp = new Excel.Application();
// Создаём экземпляр рабочий книги Excel
Excel.Workbook workBook;
// Создаём экземпляр листа Excel
Excel.Worksheet workSheet;
workBook = excelApp.Workbooks.Add();
workSheet = (Excel.Worksheet)workBook.Worksheets.get_Item(1);
// Открываем созданный excel-файл
excelApp.Visible = true;
excelApp.UserControl = true;
bool q = true;
char[] Stroka2 = stroka.ToCharArray();
string alfovit = "АаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯяAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz";
char[] alfovit2 = alfovit.ToCharArray();
for (int i = 0; i < 59; i++)
{
for (int j = 0; j < stroka.Length; j++)
{
if ((alfovit2[2 * i] == Stroka2[j]) || (alfovit2[2 * i + 1] == Stroka2[j]))
{
f = f + 1;
}
}
if (f != 0)
if (q) Console.WriteLine("");
if (i != 0)
{
workSheet.Cells[1, i] = f;
}
{
Console.WriteLine("Этот символ " + alfovit2[2*i] + " встречается " + f + " раз");
q = false;
}
f = 0;
}
}
public static char[,] CreateArray(string s, int cols)
{
int rows = s.Length / cols + 1;
char[,] arr = new char[rows, cols];
int x = 0;
int y = 0;
for (int i = 0; i < s.Length; i++)
{
char c = s[i];
arr[y, x] = c;
x++;
if (x >= cols)
{
x = 0;
y++;
}
}
return arr;
}
public static void PrintArray(char[,] arr)
{
int rows = arr.GetLength(0);
int cols = arr.GetLength(1);
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < cols; col++)
{
Console.Write(arr[row, col]);
}
Console.WriteLine();
}
}
public static void SwapColumns(char[,] arr, int x1, int x2)
{
int rows = arr.GetLength(0);
for (int row = 0; row < rows; row++)
{
char c = arr[row, x1];
arr[row, x1] = arr[row, x2];
arr[row, x2] = c;
}
}
public static void SwapRows(char[,] arr, int y1, int y2)
{
int cols = arr.GetLength(1);
for (int col = 0; col < cols; col++)
{
char c = arr[y1, col];
arr[y1, col] = arr[y2, col];
arr[y2, col] = c;
}
}
public static void Main()
{
System.IO.StreamReader sr = System.IO.File.OpenText(@"C:\Users\Danil\source\repos\4 лаба перестановка табличная\4 лаба перестановка табличная\bin\Debug\netcoreapp3.1\Лиходеев.txt");
string otrivok = sr.ReadToEnd();
sr.Close(); Console.WriteLine("Введите количество столбцов:");
int l = Convert.ToInt32(Console.ReadLine());
char[,] arr = CreateArray(otrivok, l);
PrintArray(arr);
Console.WriteLine("---------");
Random r = new Random();
Random t = new Random();
Console.WriteLine("Введите сколько раз поменять столбцы:");
int p = Convert.ToInt32(Console.ReadLine());
for (int i =0;i<p ;i++ ) {
int f = r.Next(0, p-1);
int d = r.Next(0, p-1);
SwapColumns(arr, f, d);
}
PrintArray(arr);
Console.WriteLine("---------");
Console.WriteLine("Введите сколько раз поменять строки:");
int v = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < v; i++)
{
int f = r.Next(0, v-1);
int d = r.Next(0, v-1);
SwapRows(arr, f, d);
}
PrintArray(arr);
int k = 0;
Console.WriteLine("---------");
Console.WriteLine("---------");
Console.WriteLine("Частота символов в тексте:");
poisk(otrivok, k);
}
}