개정판 cbf28e29
Excel 바탕화면 흰색, Excel저장할때 파일명_날짜
Change-Id: Ifc93264d9bf8db0bb2a2d434a2e1274ce1410314
ConvertService/ServiceBase/Markus.Service.StationController/Extensions/DataExport.cs | ||
---|---|---|
63 | 63 |
|
64 | 64 |
var header = new CellStyle(); |
65 | 65 |
|
66 |
header.FillPattern.SetSolid(SpreadsheetColor.FromArgb(0, 100, 220)); |
|
66 |
//header.FillPattern.SetSolid(SpreadsheetColor.FromArgb(0, 100, 220)); |
|
67 |
header.FillPattern.SetSolid(SpreadsheetColor.FromArgb(255, 255, 225)); |
|
67 | 68 |
header.Font.Weight = ExcelFont.BoldWeight; |
68 | 69 |
header.HorizontalAlignment = HorizontalAlignmentStyle.Center; |
69 | 70 |
header.VerticalAlignment = VerticalAlignmentStyle.Center; |
... | ... | |
74 | 75 |
|
75 | 76 |
var style = new CellStyle(); |
76 | 77 |
|
77 |
style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thick); |
|
78 |
//style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thick); |
|
79 |
style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromArgb(0, 0, 0), LineStyle.Thick); |
|
78 | 80 |
|
79 | 81 |
|
80 | 82 |
|
81 | 83 |
style.HorizontalAlignment = HorizontalAlignmentStyle.Center; |
82 | 84 |
style.VerticalAlignment = VerticalAlignmentStyle.Center; |
83 |
style.Font.Color = SpreadsheetColor.FromArgb(75, 60, 50); |
|
84 |
style.FillPattern.SetSolid(SpreadsheetColor.FromArgb(126, 239, 239)); |
|
85 |
//style.Font.Color = SpreadsheetColor.FromArgb(75, 60, 50); |
|
86 |
style.Font.Color = SpreadsheetColor.FromArgb(0, 0, 0); |
|
87 |
style.FillPattern.SetSolid(SpreadsheetColor.FromArgb(255, 255, 255)); |
|
88 |
//style.FillPattern.SetSolid(SpreadsheetColor.FromArgb(126, 239, 239)); |
|
85 | 89 |
style.Font.Name = "맑은 고딕"; |
86 | 90 |
style.Font.Size = 9 * 20; |
87 | 91 |
worksheet.Cells.GetSubrangeAbsolute(0, 0, collections.Count(), headerMembers.Count() - 1).Style = style; |
... | ... | |
90 | 94 |
{ |
91 | 95 |
for (int j = 0; j < headerMembers.Count() - 1 - 1; j++) |
92 | 96 |
{ |
93 |
worksheet.Cells[line + 1, j + 1].Style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin); |
|
97 |
//worksheet.Cells[line + 1, j + 1].Style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin); |
|
98 |
worksheet.Cells[line + 1, j + 1].Style.Borders.SetBorders(MultipleBorders.Outside, SpreadsheetColor.FromArgb(0, 0, 0), LineStyle.Thin); |
|
94 | 99 |
} |
95 | 100 |
} |
96 | 101 |
|
... | ... | |
99 | 104 |
{ |
100 | 105 |
for (int j = 0; j < headerMembers.Count() - 1; j++) |
101 | 106 |
{ |
102 |
worksheet.Cells[0, j].Style.Borders.SetBorders(MultipleBorders.Right, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin); |
|
107 |
//worksheet.Cells[0, j].Style.Borders.SetBorders(MultipleBorders.Right, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin);
|
|
103 | 108 |
|
104 |
worksheet.Cells[collections.Count(), j].Style.Borders.SetBorders(MultipleBorders.Right, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin); |
|
109 |
//worksheet.Cells[collections.Count(), j].Style.Borders.SetBorders(MultipleBorders.Right, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin); |
|
110 |
worksheet.Cells[0, j].Style.Borders.SetBorders(MultipleBorders.Right, SpreadsheetColor.FromArgb(0, 0, 0), LineStyle.Thin); |
|
111 |
|
|
112 |
worksheet.Cells[collections.Count(), j].Style.Borders.SetBorders(MultipleBorders.Right, SpreadsheetColor.FromArgb(0, 0, 0), LineStyle.Thin); |
|
105 | 113 |
} |
106 | 114 |
|
107 |
worksheet.Cells[line, 0].Style.Borders.SetBorders(MultipleBorders.Bottom, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin); |
|
115 |
//worksheet.Cells[line, 0].Style.Borders.SetBorders(MultipleBorders.Bottom, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin); |
|
116 |
|
|
117 |
//worksheet.Cells[line, headerMembers.Count() - 1].Style.Borders.SetBorders(MultipleBorders.Bottom, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin); |
|
118 |
worksheet.Cells[line, 0].Style.Borders.SetBorders(MultipleBorders.Bottom, SpreadsheetColor.FromArgb(0, 0, 0), LineStyle.Thin); |
|
108 | 119 |
|
109 |
worksheet.Cells[line, headerMembers.Count() - 1].Style.Borders.SetBorders(MultipleBorders.Bottom, SpreadsheetColor.FromArgb(140, 120, 50), LineStyle.Thin);
|
|
120 |
worksheet.Cells[line, headerMembers.Count() - 1].Style.Borders.SetBorders(MultipleBorders.Bottom, SpreadsheetColor.FromArgb(0, 0, 0), LineStyle.Thin);
|
|
110 | 121 |
|
111 | 122 |
} |
112 | 123 |
|
ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/ConvertExcelDialogViewModel.cs | ||
---|---|---|
4 | 4 |
using Microsoft.Win32; |
5 | 5 |
using Telerik.Windows.Controls; |
6 | 6 |
using System.Collections.ObjectModel; |
7 |
using System; |
|
8 |
using System.Windows; |
|
7 | 9 |
|
8 | 10 |
namespace Markus.Service.StationController.ViewModel |
9 | 11 |
{ |
... | ... | |
119 | 121 |
|
120 | 122 |
#region Save |
121 | 123 |
|
122 |
public void Save(object obj) |
|
124 |
public void Save(object obj)//파일이름 경로 저장 및 파일 저장 하면 바로 저장되게!
|
|
123 | 125 |
{ |
124 |
SaveFileDialog saveFileDialog = new SaveFileDialog(); |
|
126 |
try |
|
127 |
{ |
|
125 | 128 |
|
126 |
saveFileDialog.FileName = "Document"; |
|
127 |
saveFileDialog.DefaultExt = ".txt"; |
|
128 |
saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; |
|
129 |
SaveFileDialog saveFileDialog = new SaveFileDialog(); |
|
129 | 130 |
|
130 |
if (saveFileDialog.ShowDialog() == true) |
|
131 |
{ |
|
132 |
if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName)) |
|
131 |
var today = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); |
|
132 |
|
|
133 |
saveFileDialog.FileName = "Convert_" + today; |
|
134 |
saveFileDialog.Title = "Convert_" + today; |
|
135 |
saveFileDialog.DefaultExt = ".txt"; |
|
136 |
saveFileDialog.CreatePrompt = true; |
|
137 |
saveFileDialog.OverwritePrompt = false; |
|
138 |
saveFileDialog.CheckFileExists = false; |
|
139 |
saveFileDialog.CheckPathExists = false; |
|
140 |
saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; |
|
141 |
saveFileDialog.FilterIndex = 2; |
|
142 |
saveFileDialog.RestoreDirectory = true; |
|
143 |
|
|
144 |
if (saveFileDialog.ShowDialog() == true) |
|
133 | 145 |
{ |
134 |
var extension = new System.IO.FileInfo(saveFileDialog.FileName).Extension; |
|
146 |
string filename = saveFileDialog.FileName; |
|
147 |
|
|
148 |
if (saveFileDialog.FileName.Contains("\\")) |
|
149 |
{ |
|
150 |
filename = saveFileDialog.FileName.Substring(saveFileDialog.FileName.LastIndexOf("\\") + 1); |
|
151 |
} |
|
152 |
|
|
153 |
filename = saveFileDialog.FileName.Replace(filename, "Convert_" + today); |
|
135 | 154 |
|
136 |
if (extension == ".xlsx" || extension == ".csv")
|
|
155 |
if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName))
|
|
137 | 156 |
{ |
138 |
List<HeaderMember> headers = new List<HeaderMember>(); |
|
139 |
foreach(var ItemsSource in ItemsSource) |
|
157 |
var extension = new System.IO.FileInfo(saveFileDialog.FileName).Extension; |
|
158 |
|
|
159 |
if (extension == ".xlsx" || extension == ".csv") |
|
140 | 160 |
{ |
141 |
if (ItemsSource.IsChecked == true) |
|
161 |
List<HeaderMember> headers = new List<HeaderMember>(); |
|
162 |
foreach (var ItemsSource in ItemsSource) |
|
142 | 163 |
{ |
143 |
headers.Add(new HeaderMember { HeaderName = ItemsSource.Name, Property = ItemsSource.Name }); |
|
164 |
if (ItemsSource.IsChecked == true) |
|
165 |
{ |
|
166 |
headers.Add(new HeaderMember { HeaderName = ItemsSource.Name, Property = ItemsSource.Name }); |
|
167 |
} |
|
144 | 168 |
} |
145 |
} |
|
146 | 169 |
|
147 |
DataExport dataExport = new DataExport(); |
|
148 |
dataExport.DataExportExcel(saveFileDialog.FileName, "Convert PDF", ExcelSource, headers); |
|
170 |
DataExport dataExport = new DataExport(); |
|
171 |
dataExport.DataExportExcel(filename + extension, "Convert PDF", ExcelSource, headers); |
|
172 |
} |
|
149 | 173 |
} |
150 | 174 |
} |
151 | 175 |
} |
176 |
catch (Exception ex) |
|
177 |
{ |
|
178 |
System.Windows.MessageBox.Show(ex.ToString()); |
|
179 |
} |
|
152 | 180 |
} |
153 | 181 |
|
182 |
|
|
154 | 183 |
#endregion |
155 | 184 |
|
156 | 185 |
#endregion |
ConvertService/ServiceBase/Markus.Service.StationController/ViewModel/FinalPDFExcelDialogViewModel.cs | ||
---|---|---|
127 | 127 |
{ |
128 | 128 |
SaveFileDialog saveFileDialog = new SaveFileDialog(); |
129 | 129 |
|
130 |
saveFileDialog.FileName = "Document"; |
|
131 |
saveFileDialog.DefaultExt = ".txt"; |
|
132 |
saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; |
|
130 |
var today = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); |
|
131 |
|
|
132 |
saveFileDialog.FileName = "Final_" + today; |
|
133 |
saveFileDialog.Title = "Final_" + today; |
|
134 |
saveFileDialog.DefaultExt = ".txt"; |
|
135 |
saveFileDialog.CreatePrompt = true; |
|
136 |
saveFileDialog.OverwritePrompt = false; |
|
137 |
saveFileDialog.CheckFileExists = false; |
|
138 |
saveFileDialog.CheckPathExists = false; |
|
139 |
saveFileDialog.Filter = "Csv documents (.Csv)|*.csv|Excel(2017~2019)Worksheets|*.xlsx"; |
|
140 |
saveFileDialog.FilterIndex = 2; |
|
141 |
saveFileDialog.RestoreDirectory = true; |
|
133 | 142 |
|
134 | 143 |
if (saveFileDialog.ShowDialog() == true) |
135 | 144 |
{ |
145 |
string filename = saveFileDialog.FileName; |
|
146 |
|
|
147 |
if (saveFileDialog.FileName.Contains("\\")) |
|
148 |
{ |
|
149 |
filename = saveFileDialog.FileName.Substring(saveFileDialog.FileName.LastIndexOf("\\") + 1); |
|
150 |
} |
|
151 |
|
|
152 |
filename = saveFileDialog.FileName.Replace(filename, "Final_" + today); |
|
153 |
|
|
136 | 154 |
if (!string.IsNullOrWhiteSpace(saveFileDialog.FileName)) |
137 | 155 |
{ |
156 |
|
|
138 | 157 |
var extension = new System.IO.FileInfo(saveFileDialog.FileName).Extension; |
139 | 158 |
|
140 | 159 |
if (extension == ".xlsx" || extension == ".csv") |
... | ... | |
149 | 168 |
} |
150 | 169 |
|
151 | 170 |
DataExport dataExport = new DataExport(); |
152 |
dataExport.DataExportExcel(saveFileDialog.FileName, "Final PDF", ExcelSource, headers);
|
|
171 |
dataExport.DataExportExcel(filename + extension, "Final PDF", ExcelSource, headers);//saveFileDialog.FileName
|
|
153 | 172 |
} |
154 | 173 |
} |
155 | 174 |
} |
내보내기 Unified diff