Beispiel #1
0
        private void ExporTemplate(TransferFileType type)
        {
            DataTable dt = this.filterData1.GetDataSource();

            dt.Clear();
            this.ExportFile(type, dt);
        }
Beispiel #2
0
        public static ITransferData GetTransferData(TransferFileType dataType)
        {
            switch (dataType)
            {
            case TransferFileType.Csv: return(new CsvTransferData());

            case TransferFileType.Xls: return(new XlsTransferData());

            case TransferFileType.Xlsx: return(new XlsxTransferData());

            case TransferFileType.Txt: return(new TxtTransferData());

            default: return(new XlsTransferData());
            }
        }
Beispiel #3
0
 private void ExportFile(TransferFileType type, DataTable dt = null)
 {
     if (dt == null)
     {
         dt = this.filterData1.GetDataSource();
     }
     if (dt != null)
     {
         string savePath = Dialog.GetSaveFile(TableName + TransferDataFactory.GetFileExtension(type));
         if (!string.IsNullOrEmpty(savePath))
         {
             ITransferData transfer = TransferDataFactory.GetTransferData(type);
             byte[]        bytes    = transfer.GetBytes(dt, true);
             FileHelper.WriteFile(savePath, bytes);
             if (MsgBox.Confirm("导出完毕,是否打开文件?"))
             {
                 FileHelper.OpenFile(savePath);
             }
         }
     }
 }
Beispiel #4
0
 public static string GetFileExtension(TransferFileType type)
 {
     return("." + type.ToString().ToLower());
 }