프로젝트

일반

사용자정보

개정판 cbf28e29

IDcbf28e2907836d5812b55a2d3faab4702812a38c
상위 f25fc1d9
하위 a72d2650

semi 이(가) 4년 이상 전에 추가함

Excel 바탕화면 흰색, Excel저장할때 파일명_날짜

Change-Id: Ifc93264d9bf8db0bb2a2d434a2e1274ce1410314

차이점 보기:

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

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)