This commit is contained in:
Владимир Данилов
2024-12-12 19:20:18 +04:00
parent 8b375b106e
commit df6647c3b4
2 changed files with 7 additions and 84 deletions

View File

@@ -249,100 +249,23 @@ namespace WinForms
MessageBox.Show("Docx-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
//var config = new ComponentDocumentWithChartConfig
//{
// ChartTitle = "Отчет по аккаунтам",
// LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
// Data = chartData.ToDictionary(
// entry => entry.Key,
// entry => entry.Value.Select(d => (DateTimeToInt(d.Date), (double)d.Count)).ToList()),
// FilePath = filePath,
// Header = "Заголовок аккаунта"
//};
var config = new ComponentDocumentWithChartConfig
{
ChartTitle = "Простой тест",
ChartTitle = "Отчет по аккаунтам",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = new Dictionary<string, List<(int Date, double Count)>>()
{
{ "Test", new List<(int, double)> { (1, 10.0) } }
},
Data = chartData.ToDictionary(
entry => entry.Key,
entry => entry.Value.Select(d => (DateTimeToInt(d.Date), (double)d.Count)).ToList()),
FilePath = filePath,
Header = "Тестовый отчет"
Header = "Заголовок аккаунта"
};
var documentComponent = new ComponentDocumentWithChartLineWord();
documentComponent.CreateDoc(config);
MessageBox.Show("Документ создан успешно!");
//using var dialog = new SaveFileDialog
//{
// FileName = "Отчет 3",
// Filter = "docx|*.docx"
//};
//if (dialog.ShowDialog() == DialogResult.OK)
//{
// try
// {
// var series = new List<SeriesParameters>
// {
// new() {
// SeriesName = "что-то 1",
// ValuesY = new List<double> { 10, 15, 20 },
// Color = Color.FromArgb(255, 165, 0)
// },
// new() {
// SeriesName = "что-то 2",
// ValuesY = new List<double> { 45, 34, 18 },
// Color = Color.FromArgb(105, 105, 105)
// },
// new() {
// SeriesName = "что-то 3",
// ValuesY = new List<double> { 25, 2, 7 },
// Color = Color.FromArgb(255, 255, 0)
// }
// };
// try
// {
// wordDiagramComponent1.CreateDiagramDocument(new WordDiagramInfo()
// {
// FileName = dialog.FileName,
// DocumentTitle = "Тайтл",
// DiagramTitle = "Название Диаграммы",
// LegendLayout = DiagramLegendLayout.Bottom,
// CategoriesX = new List<string> { "Первая", "Вторая", "Третья" },
// SeriesParameters = series
// });
// }
// catch (System.Runtime.InteropServices.COMException ex)
// {
// if (ex.ErrorCode == unchecked((int)0x80010001))
// {
// MessageBox.Show("Word занят или недоступен. Повторите попытку позже.");
// }
// MessageBox.Show($"Ошибка COM: {ex.Message}\nКод ошибки: {ex.ErrorCode:X}");
// }
// //MessageBox.Show("успешно!");
// }
// catch (Exception ex)
// {
// MessageBox.Show("Есть косяк: " + ex.Message, "Точно", MessageBoxButtons.OK, MessageBoxIcon.Error);
// }
//}
}
private int DateTimeToInt(DateTime date)
{

View File

@@ -13,10 +13,10 @@
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
<PackageReference Include="PutincevLibrary" Version="1.0.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.1" />
<PackageReference Include="EPPlus" Version="7.4.1" />
<PackageReference Include="NPOI" Version="2.7.1" />
<PackageReference Include="PutincevLibrary" Version="1.0.0" />
</ItemGroup>
<ItemGroup>