├── .gitignore ├── DataConvert.sln ├── DataConvert.suo ├── DataConvert.v11.suo ├── DataConvert.v12.suo ├── DataConvert ├── Class │ ├── AppCfg.cs │ ├── AppData.cs │ ├── ExcelKeyWord.cs │ ├── Global.cs │ └── IniFile.cs ├── CutImg.Designer.cs ├── CutImg.cs ├── CutImg.resx ├── DataConvert.csproj ├── DataConvert.csproj.user ├── DownLoadImg.Designer.cs ├── DownLoadImg.cs ├── DownLoadImg.resx ├── EEPlus │ ├── EPPlus 4.0.1 Documentation (chm-file).zip │ ├── EPPlus 4.0.1 Documentation (chm-file) │ │ └── EPPlus 4.0.chm │ ├── EPPlus 4.0.1 Sample.zip │ ├── EPPlus 4.0.1 Sample │ │ ├── Binaries │ │ │ ├── EPPlus.XML │ │ │ └── EPPlus.dll │ │ ├── EPPlus.sln │ │ ├── EPPlusExcelCalculationSample │ │ │ ├── App.config │ │ │ ├── ConvertUtil.cs │ │ │ ├── EPPlusExcelCalculationDemo.csproj │ │ │ ├── ExcelForm.Designer.cs │ │ │ ├── ExcelForm.cs │ │ │ ├── ExcelForm.resx │ │ │ ├── Functions.Designer.cs │ │ │ ├── Functions.cs │ │ │ ├── Functions.resx │ │ │ ├── Program.cs │ │ │ └── Properties │ │ │ │ ├── AssemblyInfo.cs │ │ │ │ ├── Resources.Designer.cs │ │ │ │ ├── Resources.resx │ │ │ │ ├── Settings.Designer.cs │ │ │ │ └── Settings.settings │ │ ├── EPPlusWebSample │ │ │ ├── Default.aspx │ │ │ ├── Default.aspx.cs │ │ │ ├── Default.aspx.designer.cs │ │ │ ├── EPPlusWebSample.csproj │ │ │ ├── GetSample.aspx │ │ │ ├── GetSample.aspx.cs │ │ │ ├── GetSample.aspx.designer.cs │ │ │ ├── Properties │ │ │ │ └── AssemblyInfo.cs │ │ │ └── Web.config │ │ ├── SampleApp │ │ │ ├── EPPlusSamples.csproj │ │ │ ├── GraphTemplate.xlsx │ │ │ ├── Properties │ │ │ │ └── AssemblyInfo.cs │ │ │ ├── Sample1.cs │ │ │ ├── Sample10.cs │ │ │ ├── Sample11.cs │ │ │ ├── Sample12.cs │ │ │ ├── Sample13.cs │ │ │ ├── Sample14.cs │ │ │ ├── Sample15.cs │ │ │ ├── Sample16.cs │ │ │ ├── Sample2.cs │ │ │ ├── Sample3.cs │ │ │ ├── Sample4.cs │ │ │ ├── Sample5.cs │ │ │ ├── Sample6.cs │ │ │ ├── Sample7.cs │ │ │ ├── Sample8.cs │ │ │ ├── Sample9.cs │ │ │ ├── Sample_AddFormulaFunction.cs │ │ │ ├── Sample_FormulaCalc.cs │ │ │ ├── Sample_Main.cs │ │ │ ├── VBA-Code │ │ │ │ ├── BattleshipSheet.txt │ │ │ │ ├── CodeModule.txt │ │ │ │ ├── ComputerPlayModule.txt │ │ │ │ ├── ShipClass.txt │ │ │ │ └── ThisWorkbook.txt │ │ │ ├── app.config │ │ │ └── csv │ │ │ │ ├── Sample9-1.txt │ │ │ │ └── Sample9-2.txt │ │ └── readme.txt │ ├── EPPlus 4.0.1.zip │ ├── EPPlus.XML │ ├── EPPlus.dll │ └── readme.txt ├── FormMain.Designer.cs ├── FormMain.cs ├── FormMain.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── README.md ├── Res │ ├── icon.ico │ └── notifity.ico ├── app.config ├── bin │ └── Debug │ │ └── 策划 │ │ └── xlsx │ │ └── 数值 │ │ └── test.xlsx └── libiconv-2.dll └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | DataConvert/obj/ 2 | DataConvert/bin/Debug/策划/json/RuneCompound.json 3 | DataConvert/bin/Debug/策划/json/ 4 | DataConvert/bin/Debug/策划/txt/ 5 | DataConvert/bin/Debug/DataConvert.exe 6 | DataConvert/bin/Debug/DataConvert.exe.Config 7 | DataConvert/bin/Debug/DataConvert.pdb 8 | DataConvert/bin/Debug/DataConvert.vshost.exe 9 | DataConvert/bin/Debug/DataConvert.vshost.exe.Config 10 | DataConvert/bin/Debug/DataConvert.vshost.exe.manifest 11 | DataConvert/bin/Debug/EPPlus.dll 12 | DataConvert/bin/Debug/EPPlus.xml 13 | DataConvert/bin/Debug/Microsoft.Office.Interop.Excel.dll 14 | DataConvert/bin/Debug/Microsoft.Office.Interop.Excel.xml 15 | DataConvert/bin/Debug/Microsoft.Vbe.Interop.dll 16 | DataConvert/bin/Debug/office.dll 17 | DataConvert/bin/Debug/office.xml 18 | DataConvert/bin/Debug/stdole.dll 19 | -------------------------------------------------------------------------------- /DataConvert.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataConvert", "DataConvert\DataConvert.csproj", "{2312262D-930F-412A-8F27-9C62F14BBE3A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2312262D-930F-412A-8F27-9C62F14BBE3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2312262D-930F-412A-8F27-9C62F14BBE3A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2312262D-930F-412A-8F27-9C62F14BBE3A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2312262D-930F-412A-8F27-9C62F14BBE3A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /DataConvert.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert.suo -------------------------------------------------------------------------------- /DataConvert.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert.v11.suo -------------------------------------------------------------------------------- /DataConvert.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert.v12.suo -------------------------------------------------------------------------------- /DataConvert/Class/AppCfg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Configuration; 7 | 8 | 9 | public enum EnumGenType { 10 | All = 0, 11 | Server = 1, 12 | Client = 2, 13 | } 14 | 15 | namespace DataConvert { 16 | class AppCfg { 17 | public static string selectIndex = "selectIndex"; 18 | public static string batFilePath = "batFile"; 19 | public static string genType = "genType";// 生成的类型 20 | public static string localImgDir = "localImgDir";// 本地目录 21 | 22 | 23 | 24 | public static Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 25 | public static void setItem(string key, string value) { 26 | System.Configuration.KeyValueConfigurationElement b = AppCfg.cfg.AppSettings.Settings[key]; 27 | if (b == null) { 28 | AppCfg.cfg.AppSettings.Settings.Add(key, "0"); 29 | } 30 | AppCfg.cfg.AppSettings.Settings[key].Value = value; 31 | AppCfg.cfg.Save(); 32 | } 33 | public static string getItem(string key) { 34 | string s = System.Configuration.ConfigurationManager.AppSettings[key]; 35 | if (s == null) { 36 | return null; 37 | } else { 38 | return s.ToString(); 39 | } 40 | } 41 | private void init() { 42 | //System.Configuration.ConfigurationManager.RefreshSection(string sectionName); 43 | 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /DataConvert/Class/AppData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using System.Configuration; 8 | 9 | namespace DataConvert { 10 | class AppData { 11 | public static string exePath = Application.StartupPath;// exe 启动路径 12 | public static List rootListDir = new List();// 根目录列表 13 | public static EnumGenType genType = EnumGenType.All;// 生成的类型 14 | 15 | public static void init() { 16 | // 生成的类型 17 | string genType = AppCfg.getItem(AppCfg.genType); 18 | if (genType == null) { 19 | AppData.genType = EnumGenType.All; 20 | } else { 21 | AppData.genType = (EnumGenType)int.Parse(genType); 22 | } 23 | 24 | 25 | 26 | } 27 | public static void setGenType(EnumGenType type) { 28 | AppData.genType = type; 29 | AppCfg.setItem(AppCfg.genType, type.ToString()); 30 | } 31 | public static EnumGenType getGenType() { 32 | return AppData.genType; 33 | } 34 | 35 | // 保存配置 36 | public static void saveCfg() { 37 | int genType = (int)(AppData.genType); 38 | AppCfg.setItem(AppCfg.genType, genType.ToString()); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /DataConvert/Class/ExcelKeyWord.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DataConvert.Class { 8 | class ExcelKeyWord { 9 | 10 | public static string type = "type"; 11 | public static string server = "server"; 12 | public static string client = "client"; 13 | public static string began = "began"; 14 | public static string end = "end"; 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DataConvert/Class/IniFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | namespace DataConvert 8 | { 9 | class IniFile 10 | { 11 | private List listContent = new List(); 12 | private List listToken = new List(); 13 | private int nLastLine = 0; 14 | 15 | public IniFile() 16 | { 17 | 18 | } 19 | 20 | public bool Load(string strFile) 21 | { 22 | try 23 | { 24 | this.listContent.Clear(); 25 | using (StreamReader sr = new StreamReader(strFile, Encoding.GetEncoding("GBK"))) 26 | { 27 | string line; 28 | while ((line = sr.ReadLine()) != null) 29 | { 30 | line = line.Trim(); 31 | if (line.Length == 0) continue; 32 | if (line.Substring(0, 1) == "#") continue; 33 | if (line.Substring(0, 1) == ";") continue; 34 | this.listContent.Add(line); 35 | } 36 | sr.Close(); 37 | return true; 38 | } 39 | } 40 | catch (Exception ex) 41 | { 42 | Console.WriteLine(ex.Message); 43 | return false; 44 | } 45 | } 46 | 47 | public string GetString(string strSection, string strItem, string strValue) 48 | { 49 | string strResult = strValue; 50 | strSection = "[" + strSection + "]"; 51 | bool bFindSection = false; 52 | int nTempLine = this.nLastLine; 53 | for (int i = 0; i < this.listContent.Count; i++) 54 | { 55 | int t = (nTempLine + i) % this.listContent.Count; 56 | string s = this.listContent[t]; 57 | if (s.Substring(0, 1) == "[") 58 | { 59 | if (bFindSection) break; //找到下一个section 60 | if (s == strSection) 61 | { 62 | bFindSection = true; 63 | this.nLastLine = t; 64 | } 65 | } 66 | else 67 | { 68 | if (bFindSection) 69 | { 70 | int nEqual = s.IndexOf("="); 71 | if ((nEqual <= 0) || (nEqual == s.Length - 1)) continue; 72 | string s1 = s.Substring(0, nEqual).Trim(); 73 | string s2 = s.Substring(nEqual + 1).Trim(); 74 | if (s1 != strItem) continue; 75 | strResult = s2; 76 | break; 77 | } 78 | } 79 | } 80 | return strResult; 81 | } 82 | 83 | public uint GetDec(string strSection, string strItem, uint nValue) 84 | { 85 | string s = this.GetString(strSection, strItem, ""); 86 | if (s.Length == 0) return nValue; 87 | try 88 | { 89 | return Convert.ToUInt32(s, 10); 90 | } 91 | catch (Exception ex) 92 | { 93 | return nValue; 94 | } 95 | } 96 | 97 | public uint GetHex(string strSection, string strItem, uint nValue) 98 | { 99 | string s = this.GetString(strSection, strItem, ""); 100 | if (s.Length == 0) return nValue; 101 | try 102 | { 103 | return Convert.ToUInt32(s, 16); 104 | } 105 | catch (Exception ex) 106 | { 107 | return nValue; 108 | } 109 | } 110 | 111 | public uint GetTokenCount(string strSection, string strItem, string strValue) 112 | { 113 | this.listToken.Clear(); 114 | string s = this.GetString(strSection, strItem, ""); 115 | if (s.Length == 0) return 0; 116 | string[] arr = s.Split(','); 117 | for (int i = 0; i < arr.Length; i++) 118 | { 119 | string ss = arr[i].Trim(); 120 | this.listToken.Add(ss); 121 | } 122 | return (uint)this.listToken.Count; 123 | } 124 | 125 | public string GetTokenString(int nIndex) 126 | { 127 | string strResult = ""; 128 | if ((nIndex < 0) || (nIndex >= this.listToken.Count)) 129 | return strResult; 130 | return this.listToken[nIndex]; 131 | } 132 | 133 | public uint GetTokenHex(int nIndex) 134 | { 135 | uint nResult = 0; 136 | if ((nIndex < 0) || (nIndex >= this.listToken.Count)) 137 | return nResult; 138 | try 139 | { 140 | return Convert.ToUInt32(this.listToken[nIndex], 16); 141 | } 142 | catch (Exception ex) 143 | { 144 | return nResult; 145 | } 146 | } 147 | 148 | public uint GetTokenDec(int nIndex) 149 | { 150 | uint nResult = 0; 151 | if ((nIndex < 0) || (nIndex >= this.listToken.Count)) 152 | return nResult; 153 | try 154 | { 155 | return Convert.ToUInt32(this.listToken[nIndex], 10); 156 | } 157 | catch (Exception ex) 158 | { 159 | return nResult; 160 | } 161 | } 162 | } 163 | } -------------------------------------------------------------------------------- /DataConvert/CutImg.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 107, 17 125 | 126 | 127 | 287, 17 128 | 129 | -------------------------------------------------------------------------------- /DataConvert/DataConvert.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {2312262D-930F-412A-8F27-9C62F14BBE3A} 9 | WinExe 10 | Properties 11 | DataConvert 12 | DataConvert 13 | v4.5 14 | 512 15 | 16 | 17 | 18 | 19 | 3.5 20 | 21 | false 22 | 发布\ 23 | true 24 | Disk 25 | false 26 | Foreground 27 | 7 28 | Days 29 | false 30 | false 31 | true 32 | 0 33 | 1.0.0.%2a 34 | false 35 | true 36 | 37 | 38 | true 39 | full 40 | false 41 | bin\Debug\ 42 | DEBUG;TRACE 43 | prompt 44 | 4 45 | false 46 | 47 | 48 | pdbonly 49 | true 50 | bin\Release\ 51 | TRACE 52 | prompt 53 | 4 54 | false 55 | 56 | 57 | 58 | 59 | Res\icon.ico 60 | 61 | 62 | 63 | False 64 | EEPlus\EPPlus.dll 65 | 66 | 67 | 68 | 69 | 3.5 70 | 71 | 72 | 3.5 73 | 74 | 75 | 3.5 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | Form 89 | 90 | 91 | CutImg.cs 92 | 93 | 94 | Form 95 | 96 | 97 | DownLoadImg.cs 98 | 99 | 100 | Form 101 | 102 | 103 | FormMain.cs 104 | 105 | 106 | 107 | 108 | 109 | 110 | CutImg.cs 111 | 112 | 113 | DownLoadImg.cs 114 | 115 | 116 | FormMain.cs 117 | Designer 118 | 119 | 120 | ResXFileCodeGenerator 121 | Resources.Designer.cs 122 | Designer 123 | 124 | 125 | True 126 | Resources.resx 127 | True 128 | 129 | 130 | 131 | SettingsSingleFileGenerator 132 | Settings.Designer.cs 133 | 134 | 135 | True 136 | Settings.settings 137 | True 138 | 139 | 140 | 141 | 142 | False 143 | .NET Framework 3.5 SP1 Client Profile 144 | false 145 | 146 | 147 | False 148 | .NET Framework 3.5 SP1 149 | true 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52} 158 | 2 159 | 7 160 | 0 161 | primary 162 | False 163 | True 164 | 165 | 166 | {00020813-0000-0000-C000-000000000046} 167 | 1 168 | 8 169 | 0 170 | primary 171 | False 172 | False 173 | 174 | 175 | {EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B} 176 | 1 177 | 1 178 | 0 179 | tlbimp 180 | False 181 | True 182 | 183 | 184 | {0002E157-0000-0000-C000-000000000046} 185 | 5 186 | 3 187 | 0 188 | primary 189 | False 190 | True 191 | 192 | 193 | 194 | 201 | -------------------------------------------------------------------------------- /DataConvert/DataConvert.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 发布\ 5 | 6 | 7 | 8 | 9 | 10 | zh-CN 11 | false 12 | 13 | -------------------------------------------------------------------------------- /DataConvert/DownLoadImg.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DataConvert { 2 | partial class DownLoadImg { 3 | /// 4 | /// Required designer variable. 5 | /// 6 | private System.ComponentModel.IContainer components = null; 7 | 8 | /// 9 | /// Clean up any resources being used. 10 | /// 11 | /// true if managed resources should be disposed; otherwise, false. 12 | protected override void Dispose(bool disposing) { 13 | if (disposing && (components != null)) { 14 | components.Dispose(); 15 | } 16 | base.Dispose(disposing); 17 | } 18 | 19 | #region Windows Form Designer generated code 20 | 21 | /// 22 | /// Required method for Designer support - do not modify 23 | /// the contents of this method with the code editor. 24 | /// 25 | private void InitializeComponent() { 26 | this.components = new System.ComponentModel.Container(); 27 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DownLoadImg)); 28 | this.downBtn = new System.Windows.Forms.Button(); 29 | this.imgUrlTextBox = new System.Windows.Forms.TextBox(); 30 | this.label1 = new System.Windows.Forms.Label(); 31 | this.button1 = new System.Windows.Forms.Button(); 32 | this.localDirTextBox = new System.Windows.Forms.TextBox(); 33 | this.label2 = new System.Windows.Forms.Label(); 34 | this.localDirBtn = new System.Windows.Forms.Button(); 35 | this.logListView = new System.Windows.Forms.ListView(); 36 | this.listTitle1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 37 | this.openLocalDirBtn = new System.Windows.Forms.Button(); 38 | this.label3 = new System.Windows.Forms.Label(); 39 | this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); 40 | this.SuspendLayout(); 41 | // 42 | // downBtn 43 | // 44 | this.downBtn.Location = new System.Drawing.Point(463, 104); 45 | this.downBtn.Name = "downBtn"; 46 | this.downBtn.Size = new System.Drawing.Size(62, 23); 47 | this.downBtn.TabIndex = 0; 48 | this.downBtn.Text = "下载"; 49 | this.downBtn.UseVisualStyleBackColor = true; 50 | this.downBtn.Click += new System.EventHandler(this.downBtn_Click); 51 | // 52 | // imgUrlTextBox 53 | // 54 | this.imgUrlTextBox.Location = new System.Drawing.Point(12, 106); 55 | this.imgUrlTextBox.Name = "imgUrlTextBox"; 56 | this.imgUrlTextBox.Size = new System.Drawing.Size(369, 21); 57 | this.imgUrlTextBox.TabIndex = 1; 58 | this.imgUrlTextBox.Enter += new System.EventHandler(this.imgUrlTextBox_Enter); 59 | // 60 | // label1 61 | // 62 | this.label1.AutoSize = true; 63 | this.label1.Location = new System.Drawing.Point(10, 88); 64 | this.label1.Name = "label1"; 65 | this.label1.Size = new System.Drawing.Size(53, 12); 66 | this.label1.TabIndex = 2; 67 | this.label1.Text = "图片网址"; 68 | // 69 | // button1 70 | // 71 | this.button1.Location = new System.Drawing.Point(388, 104); 72 | this.button1.Name = "button1"; 73 | this.button1.Size = new System.Drawing.Size(56, 23); 74 | this.button1.TabIndex = 3; 75 | this.button1.Text = "遍历"; 76 | this.button1.UseVisualStyleBackColor = true; 77 | this.button1.Click += new System.EventHandler(this.button1_Click); 78 | // 79 | // localDirTextBox 80 | // 81 | this.localDirTextBox.Location = new System.Drawing.Point(12, 56); 82 | this.localDirTextBox.Name = "localDirTextBox"; 83 | this.localDirTextBox.ReadOnly = true; 84 | this.localDirTextBox.Size = new System.Drawing.Size(369, 21); 85 | this.localDirTextBox.TabIndex = 4; 86 | this.localDirTextBox.TextChanged += new System.EventHandler(this.localDirTextBox_TextChanged); 87 | // 88 | // label2 89 | // 90 | this.label2.AutoSize = true; 91 | this.label2.Location = new System.Drawing.Point(10, 39); 92 | this.label2.Name = "label2"; 93 | this.label2.Size = new System.Drawing.Size(53, 12); 94 | this.label2.TabIndex = 5; 95 | this.label2.Text = "存放目录"; 96 | // 97 | // localDirBtn 98 | // 99 | this.localDirBtn.Location = new System.Drawing.Point(388, 54); 100 | this.localDirBtn.Name = "localDirBtn"; 101 | this.localDirBtn.Size = new System.Drawing.Size(49, 23); 102 | this.localDirBtn.TabIndex = 6; 103 | this.localDirBtn.Text = "..."; 104 | this.localDirBtn.UseVisualStyleBackColor = true; 105 | this.localDirBtn.Click += new System.EventHandler(this.localDirBtn_Click); 106 | // 107 | // logListView 108 | // 109 | this.logListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 110 | this.listTitle1}); 111 | this.logListView.Location = new System.Drawing.Point(0, 261); 112 | this.logListView.Name = "logListView"; 113 | this.logListView.Size = new System.Drawing.Size(525, 159); 114 | this.logListView.TabIndex = 7; 115 | this.logListView.UseCompatibleStateImageBehavior = false; 116 | this.logListView.View = System.Windows.Forms.View.Details; 117 | // 118 | // listTitle1 119 | // 120 | this.listTitle1.Text = "msg"; 121 | this.listTitle1.Width = 507; 122 | // 123 | // openLocalDirBtn 124 | // 125 | this.openLocalDirBtn.Location = new System.Drawing.Point(443, 54); 126 | this.openLocalDirBtn.Name = "openLocalDirBtn"; 127 | this.openLocalDirBtn.Size = new System.Drawing.Size(75, 23); 128 | this.openLocalDirBtn.TabIndex = 8; 129 | this.openLocalDirBtn.Text = "打开目录"; 130 | this.openLocalDirBtn.UseVisualStyleBackColor = true; 131 | this.openLocalDirBtn.Click += new System.EventHandler(this.openLocalDirBtn_Click); 132 | // 133 | // label3 134 | // 135 | this.label3.AutoSize = true; 136 | this.label3.Location = new System.Drawing.Point(10, 9); 137 | this.label3.Name = "label3"; 138 | this.label3.Size = new System.Drawing.Size(215, 12); 139 | this.label3.TabIndex = 9; 140 | this.label3.Text = "Alt+Q键 快捷下载 Alt+A 打开下载目录"; 141 | // 142 | // notifyIcon1 143 | // 144 | this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); 145 | this.notifyIcon1.Text = "notifyIcon1"; 146 | this.notifyIcon1.Visible = true; 147 | // 148 | // DownLoadImg 149 | // 150 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 151 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 152 | this.ClientSize = new System.Drawing.Size(526, 418); 153 | this.Controls.Add(this.label3); 154 | this.Controls.Add(this.openLocalDirBtn); 155 | this.Controls.Add(this.logListView); 156 | this.Controls.Add(this.localDirBtn); 157 | this.Controls.Add(this.label2); 158 | this.Controls.Add(this.localDirTextBox); 159 | this.Controls.Add(this.button1); 160 | this.Controls.Add(this.label1); 161 | this.Controls.Add(this.imgUrlTextBox); 162 | this.Controls.Add(this.downBtn); 163 | this.Name = "DownLoadImg"; 164 | this.Text = "图片下载小助手"; 165 | this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.DownLoadImg_FormClosed); 166 | this.Load += new System.EventHandler(this.DownLoadImg_Load); 167 | this.ResumeLayout(false); 168 | this.PerformLayout(); 169 | 170 | } 171 | 172 | #endregion 173 | 174 | private System.Windows.Forms.Button downBtn; 175 | private System.Windows.Forms.TextBox imgUrlTextBox; 176 | private System.Windows.Forms.Label label1; 177 | private System.Windows.Forms.Button button1; 178 | private System.Windows.Forms.TextBox localDirTextBox; 179 | private System.Windows.Forms.Label label2; 180 | private System.Windows.Forms.Button localDirBtn; 181 | private System.Windows.Forms.ListView logListView; 182 | private System.Windows.Forms.ColumnHeader listTitle1; 183 | private System.Windows.Forms.Button openLocalDirBtn; 184 | private System.Windows.Forms.Label label3; 185 | private System.Windows.Forms.NotifyIcon notifyIcon1; 186 | } 187 | } -------------------------------------------------------------------------------- /DataConvert/DownLoadImg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using System.Net; 11 | using SHDocVw; 12 | using System.Runtime.InteropServices; 13 | 14 | namespace DataConvert { 15 | public partial class DownLoadImg : Form { 16 | public static bool isShow = false; 17 | public static DownLoadImg instance = null; 18 | class Win32API { 19 | [DllImport("User32.dll")] 20 | public static extern bool PtInRect(ref Rectangle r, Point p); 21 | [DllImport("user32.dll")] 22 | public static extern bool SetForegroundWindow(IntPtr hWnd); 23 | } 24 | 25 | public DownLoadImg() { 26 | InitializeComponent(); 27 | DownLoadImg.isShow = true; 28 | DownLoadImg.instance = this; 29 | } 30 | 31 | private void DownLoadImg_Load(object sender, EventArgs e) { 32 | this.initHotKey(); 33 | string dir = AppCfg.getItem(AppCfg.localImgDir); 34 | if (dir != null) { 35 | this.localDirTextBox.Text = dir; 36 | } 37 | } 38 | #region 注册热键 39 | //注册热键的api 40 | [DllImport("user32")] 41 | public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint control, Keys vk); 42 | //解除注册热键的api 43 | [DllImport("user32")] 44 | public static extern bool UnregisterHotKey(IntPtr hWnd, int id); 45 | private void initHotKey() { 46 | /* 47 | //注册热键Shift+S,Id号为100。HotKey.KeyModifiers.Shift也可以直接使用数字4来表示。 48 | HotKey.RegisterHotKey(Handle, 100, HotKey.KeyModifiers.Shift, Keys.S); 49 | //注册热键Ctrl+B,Id号为101。HotKey.KeyModifiers.Ctrl也可以直接使用数字2来表示。 50 | HotKey.RegisterHotKey(Handle, 101, HotKey.KeyModifiers.Ctrl, Keys.B); 51 | //注册热键Ctrl+Alt+D,Id号为102。HotKey.KeyModifiers.Alt也可以直接使用数字1来表示。 52 | HotKey.RegisterHotKey(Handle, 102, HotKey.KeyModifiers.Alt | HotKey.KeyModifiers.Ctrl, Keys.D); 53 | //注册热键F5,Id号为103。 54 | HotKey.RegisterHotKey(Handle, 103, HotKey.KeyModifiers.None, Keys.F5); 55 | */ 56 | 57 | 58 | //注册热键 (窗体句柄,热键ID,辅助键,实键) 59 | //辅助键说明: None = 0, Alt = 1, crtl= 2, Shift = 4, Windows = 8 60 | //如果有多个辅助键则,例如 alt+crtl是3 直接相加就可以了 61 | RegisterHotKey(this.Handle, 123, 1, Keys.Q); 62 | RegisterHotKey(this.Handle, 124, 1, Keys.A); 63 | } 64 | 65 | private void DownLoadImg_FormClosed(object sender, FormClosedEventArgs e) { 66 | UnregisterHotKey(this.Handle, 123); 67 | UnregisterHotKey(this.Handle, 124); 68 | DownLoadImg.isShow = false; 69 | DownLoadImg.instance = null; 70 | } 71 | private bool isPressHotKey = false; 72 | protected override void WndProc(ref Message m) { 73 | switch (m.Msg) { 74 | case 0x0312: //这个是window消息定义的注册的热键消息 75 | this.isPressHotKey = true; 76 | switch (m.WParam.ToInt32()) {// 按下CTRL+Q 77 | case 123: { 78 | // 将剪切板的内容复制出来 79 | this.imgUrlTextBox_Enter(null, null); 80 | // 下载 81 | this.downBtn_Click(null, null); 82 | break; 83 | } 84 | case 124: { 85 | this.openLocalDirBtn_Click(null, null); 86 | break; 87 | } 88 | } 89 | this.isPressHotKey = false; 90 | break; 91 | } 92 | base.WndProc(ref m); 93 | } 94 | #endregion 95 | 96 | 97 | 98 | private void addLog(string str) { 99 | this.logListView.Items.Add(str); 100 | 101 | // 滚动到底部 102 | int index = this.logListView.Items.Count; 103 | this.logListView.Items[index - 1].EnsureVisible(); 104 | 105 | 106 | if (this.isPressHotKey == true) { 107 | this.showNotifity(str); 108 | } 109 | 110 | } 111 | private void showNotifity(string str) { 112 | this.notifyIcon1.Text = str; 113 | this.notifyIcon1.Visible = true; 114 | this.notifyIcon1.ShowBalloonTip(1000, "提示", str, ToolTipIcon.Info); 115 | } 116 | private void downBtn_Click(object sender, EventArgs e) { 117 | string url = this.imgUrlTextBox.Text; 118 | if (url.Length > 0) { 119 | int pos = url.IndexOf("http"); 120 | if (pos < 0) { 121 | this.addLog("不是合法的网址" + url); 122 | } else { 123 | string dir = this.localDirTextBox.Text; 124 | if (dir.Length > 0) { 125 | string[] urlArray = url.Split('/'); 126 | string fileName = urlArray[urlArray.Length - 1]; 127 | string[] fileArr = fileName.Split('.'); 128 | string fileNamefile = fileArr[0]; 129 | string fileExt = fileArr[1]; 130 | string path = dir + "\\" + fileName; 131 | try { 132 | WebClient client = new WebClient(); 133 | client.DownloadFile(url, path); 134 | this.addLog("文件下载完成: " + fileName); ; 135 | } catch (Exception ex) { 136 | this.addLog("文件下载出错: " + fileName); 137 | 138 | } 139 | } else { 140 | this.addLog("请选择文件存放目录"); 141 | } 142 | } 143 | } else { 144 | this.addLog("请输入下载地址"); 145 | } 146 | } 147 | 148 | private void button1_Click(object sender, EventArgs e) { 149 | 150 | } 151 | 152 | private void localDirBtn_Click(object sender, EventArgs e) { 153 | FolderBrowserDialog dlg = new FolderBrowserDialog(); 154 | dlg.Description = "请选择图片存放文件夹"; 155 | if (dlg.ShowDialog() == DialogResult.OK) { 156 | string filepach = dlg.SelectedPath;//得到路径 157 | this.localDirTextBox.Text = filepach; 158 | AppCfg.setItem(AppCfg.localImgDir, filepach); 159 | }; 160 | } 161 | 162 | private void localDirTextBox_TextChanged(object sender, EventArgs e) { 163 | return; 164 | string filepach = this.localDirTextBox.Text; 165 | AppCfg.setItem(AppCfg.localImgDir, filepach); 166 | } 167 | 168 | private void imgUrlTextBox_Enter(object sender, EventArgs e) { 169 | IDataObject iData = Clipboard.GetDataObject(); 170 | if (iData.GetDataPresent(DataFormats.Text)) { 171 | this.imgUrlTextBox.Text = (String)iData.GetData(DataFormats.Text); 172 | 173 | 174 | } 175 | } 176 | 177 | private void openLocalDirBtn_Click(object sender, EventArgs e) { 178 | string dir = this.localDirTextBox.Text; 179 | if (dir != null) { 180 | if (this.onShowExplorePath(dir) == false) { 181 | System.Diagnostics.Process.Start("Explorer.exe", dir); 182 | } 183 | 184 | } else { 185 | this.addLog("目录为空,不能打开"); 186 | } 187 | } 188 | 189 | private bool onShowExplorePath(string path) { 190 | bool isFind = false; 191 | ShellWindows wins = new ShellWindows(); 192 | foreach (InternetExplorer w in wins) { 193 | if (w.LocationURL.Contains(path.Replace('\\', '/'))) { 194 | // 找到了窗口就置顶 195 | Win32API.SetForegroundWindow((IntPtr)w.HWND); 196 | isFind = true; 197 | break; 198 | } 199 | } 200 | return isFind; 201 | } 202 | 203 | 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Documentation (chm-file).zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus 4.0.1 Documentation (chm-file).zip -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Documentation (chm-file)/EPPlus 4.0.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus 4.0.1 Documentation (chm-file)/EPPlus 4.0.chm -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus 4.0.1 Sample.zip -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/Binaries/EPPlus.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus 4.0.1 Sample/Binaries/EPPlus.dll -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlus.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{84BB37E9-CE27-48E0-88F6-A741A46D5883}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EPPlusSamples", "SampleApp\EPPlusSamples.csproj", "{06BF3C68-E7D4-4579-90BE-E36DACE564EF}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EPPlusWebSample", "EPPlusWebSample\EPPlusWebSample.csproj", "{1BF30A52-6149-432D-82F6-725250E5C662}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EPPlusExcelCalculationDemo", "EPPlusExcelCalculationSample\EPPlusExcelCalculationDemo.csproj", "{94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Debug|Mixed Platforms = Debug|Mixed Platforms 18 | Debug|x86 = Debug|x86 19 | Release|Any CPU = Release|Any CPU 20 | Release|Mixed Platforms = Release|Mixed Platforms 21 | Release|x86 = Release|x86 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 27 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 28 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Debug|x86.ActiveCfg = Debug|Any CPU 29 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 32 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Release|Mixed Platforms.Build.0 = Release|Any CPU 33 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Release|x86.ActiveCfg = Release|Any CPU 34 | {1BF30A52-6149-432D-82F6-725250E5C662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {1BF30A52-6149-432D-82F6-725250E5C662}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {1BF30A52-6149-432D-82F6-725250E5C662}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 37 | {1BF30A52-6149-432D-82F6-725250E5C662}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 38 | {1BF30A52-6149-432D-82F6-725250E5C662}.Debug|x86.ActiveCfg = Debug|Any CPU 39 | {1BF30A52-6149-432D-82F6-725250E5C662}.Release|Any CPU.ActiveCfg = Release|Any CPU 40 | {1BF30A52-6149-432D-82F6-725250E5C662}.Release|Any CPU.Build.0 = Release|Any CPU 41 | {1BF30A52-6149-432D-82F6-725250E5C662}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 42 | {1BF30A52-6149-432D-82F6-725250E5C662}.Release|Mixed Platforms.Build.0 = Release|Any CPU 43 | {1BF30A52-6149-432D-82F6-725250E5C662}.Release|x86.ActiveCfg = Release|Any CPU 44 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 47 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 48 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Debug|x86.ActiveCfg = Debug|Any CPU 49 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Release|Any CPU.ActiveCfg = Release|Any CPU 50 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Release|Any CPU.Build.0 = Release|Any CPU 51 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 52 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Release|Mixed Platforms.Build.0 = Release|Any CPU 53 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}.Release|x86.ActiveCfg = Release|Any CPU 54 | EndGlobalSection 55 | GlobalSection(SolutionProperties) = preSolution 56 | HideSolutionNode = FALSE 57 | EndGlobalSection 58 | GlobalSection(ExtensibilityGlobals) = postSolution 59 | VisualSVNWorkingCopyRoot = . 60 | EndGlobalSection 61 | EndGlobal 62 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/ConvertUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Text.RegularExpressions; 7 | using System.Threading.Tasks; 8 | 9 | namespace EPPlusExcelFormDemo 10 | { 11 | internal static class ConvertUtil 12 | { 13 | internal static bool IsNumeric(object candidate) 14 | { 15 | if (candidate == null) return false; 16 | return (candidate.GetType().IsPrimitive || candidate is double || candidate is decimal || candidate is DateTime || candidate is TimeSpan || candidate is long); 17 | } 18 | 19 | internal static bool IsNumericString(object candidate) 20 | { 21 | if (candidate != null) 22 | { 23 | return Regex.IsMatch(candidate.ToString(), @"^[\d]+(\,[\d])?"); 24 | } 25 | return false; 26 | } 27 | 28 | /// 29 | /// Convert an object value to a double 30 | /// 31 | /// 32 | /// 33 | /// 34 | internal static double GetValueDouble(object v, bool ignoreBool = false) 35 | { 36 | double d; 37 | try 38 | { 39 | if (ignoreBool && v is bool) 40 | { 41 | return 0; 42 | } 43 | if (IsNumeric(v)) 44 | { 45 | if (v is DateTime) 46 | { 47 | d = ((DateTime)v).ToOADate(); 48 | } 49 | else if (v is TimeSpan) 50 | { 51 | d = new DateTime(((TimeSpan)v).Ticks).ToOADate(); 52 | } 53 | else 54 | { 55 | d = Convert.ToDouble(v, CultureInfo.InvariantCulture); 56 | } 57 | } 58 | else 59 | { 60 | d = 0; 61 | } 62 | } 63 | 64 | catch 65 | { 66 | d = 0; 67 | } 68 | return d; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/EPPlusExcelCalculationDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B} 8 | WinExe 9 | Properties 10 | EPPlusExcelFormDemo 11 | EPPlusExcelFormDemo 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\Binaries\EPPlus.dll 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Form 53 | 54 | 55 | ExcelForm.cs 56 | 57 | 58 | Form 59 | 60 | 61 | Functions.cs 62 | 63 | 64 | 65 | 66 | ExcelForm.cs 67 | 68 | 69 | Functions.cs 70 | 71 | 72 | ResXFileCodeGenerator 73 | Resources.Designer.cs 74 | Designer 75 | 76 | 77 | True 78 | Resources.resx 79 | 80 | 81 | SettingsSingleFileGenerator 82 | Settings.Designer.cs 83 | 84 | 85 | True 86 | Settings.settings 87 | True 88 | 89 | 90 | 91 | 92 | 93 | 94 | 101 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/ExcelForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | True 125 | 126 | 127 | True 128 | 129 | 130 | True 131 | 132 | 133 | True 134 | 135 | 136 | True 137 | 138 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/Functions.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace EPPlusExcelFormDemo 2 | { 3 | partial class frmFunctions 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.textBox1 = new System.Windows.Forms.TextBox(); 32 | this.SuspendLayout(); 33 | // 34 | // textBox1 35 | // 36 | this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; 37 | this.textBox1.Location = new System.Drawing.Point(0, 0); 38 | this.textBox1.Multiline = true; 39 | this.textBox1.Name = "textBox1"; 40 | this.textBox1.Size = new System.Drawing.Size(606, 679); 41 | this.textBox1.TabIndex = 0; 42 | // 43 | // frmFunctions 44 | // 45 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 46 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 47 | this.ClientSize = new System.Drawing.Size(606, 679); 48 | this.Controls.Add(this.textBox1); 49 | this.Name = "frmFunctions"; 50 | this.Text = "Functions"; 51 | this.ResumeLayout(false); 52 | this.PerformLayout(); 53 | 54 | } 55 | 56 | #endregion 57 | 58 | private System.Windows.Forms.TextBox textBox1; 59 | 60 | } 61 | } -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/Functions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace EPPlusExcelFormDemo 12 | { 13 | public partial class frmFunctions : Form 14 | { 15 | public frmFunctions() 16 | { 17 | InitializeComponent(); 18 | } 19 | public frmFunctions(List functions) 20 | { 21 | InitializeComponent(); 22 | 23 | var sb = new StringBuilder(); 24 | foreach (var f in functions) 25 | { 26 | sb.AppendLine(f.ToUpper()); 27 | } 28 | textBox1.Text = sb.ToString(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/Functions.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace EPPlusExcelFormDemo 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new ExcelForm()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("EPPlusExcelFormDemo")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("EPPlusExcelFormDemo")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1de25448-fecb-493d-ad8d-d03e6853cee5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18408 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EPPlusExcelFormDemo.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EPPlusExcelFormDemo.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18408 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EPPlusExcelFormDemo.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusExcelCalculationSample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusWebSample/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EPPlusWebSample._Default" %> 2 | 3 | 4 | 5 | 6 | 7 | EPPlus Websample 8 | 27 | 28 | 29 |
30 |

EPPlus Web samples

31 |

The web sample project shows a few different ways to send a workbook to the client.

32 | 33 | 34 | 37 | 40 | 41 | 42 | 45 | 48 | 49 | 50 | 53 | 56 | 57 | 58 | 61 | 64 | 65 |
35 | Sample 1 36 | 38 | This sample demonstrates how to output a spreadsheet using the SaveAs(Reponse.OutputSteam) method. 39 |
43 | Sample 2 44 | 46 | This sample demonstrates how to output a spreadsheet using the Response.BinaryWrite(pck.GetAsByteArray()). 47 |
51 | Sample 3 52 | 54 | This sample demonstrates how to use a template stored in the Application cashe. 55 |
59 | Sample 4 60 | 62 | This sample demonstrates how to use a macro-enabled spreadsheet. 63 |
66 |
67 | 68 | 69 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusWebSample/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Web; 4 | using System.Web.UI; 5 | using System.Web.UI.WebControls; 6 | 7 | namespace EPPlusWebSample 8 | { 9 | public partial class _Default : System.Web.UI.Page 10 | { 11 | protected void Page_Load(object sender, EventArgs e) 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusWebSample/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace EPPlusWebSample { 11 | 12 | 13 | public partial class _Default { 14 | 15 | /// 16 | /// form1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1; 23 | 24 | /// 25 | /// sample1 control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.HyperLink sample1; 32 | 33 | /// 34 | /// sample2 control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.HyperLink sample2; 41 | 42 | /// 43 | /// sample3 control. 44 | /// 45 | /// 46 | /// Auto-generated field. 47 | /// To modify move field declaration from designer file to code-behind file. 48 | /// 49 | protected global::System.Web.UI.WebControls.HyperLink sample3; 50 | 51 | /// 52 | /// sample4 control. 53 | /// 54 | /// 55 | /// Auto-generated field. 56 | /// To modify move field declaration from designer file to code-behind file. 57 | /// 58 | protected global::System.Web.UI.WebControls.HyperLink sample4; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusWebSample/EPPlusWebSample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 9.0.30729 8 | 2.0 9 | {1BF30A52-6149-432D-82F6-725250E5C662} 10 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 11 | Library 12 | Properties 13 | EPPlusWebSample 14 | EPPlusWebSample 15 | v3.5 16 | 17 | 18 | 4.0 19 | 20 | 21 | 22 | false 23 | 24 | disabled 25 | enabled 26 | false 27 | 28 | 29 | true 30 | full 31 | false 32 | bin\ 33 | DEBUG;TRACE 34 | prompt 35 | 4 36 | AllRules.ruleset 37 | false 38 | 39 | 40 | pdbonly 41 | true 42 | bin\ 43 | TRACE 44 | prompt 45 | 4 46 | AllRules.ruleset 47 | false 48 | 49 | 50 | true 51 | 52 | 53 | 54 | ..\Binaries\EPPlus.dll 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | ASPXCodeBehind 76 | Default.aspx 77 | 78 | 79 | Default.aspx 80 | 81 | 82 | GetSample.aspx 83 | ASPXCodeBehind 84 | 85 | 86 | GetSample.aspx 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 10.0 95 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 96 | 97 | 98 | bin\ 99 | false 100 | 101 | 102 | 103 | 104 | 111 | 112 | 113 | 114 | 115 | False 116 | True 117 | 8544 118 | / 119 | 120 | 121 | False 122 | False 123 | 124 | 125 | False 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusWebSample/GetSample.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetSample.aspx.cs" Inherits="EPPlusWebSample.GetSample" %> 2 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusWebSample/GetSample.aspx.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * You may amend and distribute as you like, but don't remove this header! 3 | * 4 | * All rights reserved. 5 | * 6 | * EPPlus is an Open Source project provided under the 7 | * GNU General Public License (GPL) as published by the 8 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 9 | * 10 | * See http://epplus.codeplex.com/ for details 11 | * 12 | * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php 13 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html 14 | * 15 | * The code for this project may be used and redistributed by any means PROVIDING it is 16 | * not sold for profit without the author's written consent, and providing that this notice 17 | * and the author's name and all copyright notices remain intact. 18 | * 19 | * All code and executables are provided "as is" with no warranty either express or implied. 20 | * The author accepts no liability for any damage or loss of business that this product may cause. 21 | * 22 | * Code change notes: 23 | * 24 | * Author Change Date 25 | ******************************************************************************* 26 | * Jan Källman Added 23-MAR-2010 27 | *******************************************************************************/ 28 | using System; 29 | using System.Collections.Generic; 30 | using System.Web; 31 | using System.Web.UI; 32 | using System.Web.UI.WebControls; 33 | using OfficeOpenXml; 34 | using System.IO; 35 | using OfficeOpenXml.Style; 36 | using System.Drawing; 37 | using System.Text; 38 | namespace EPPlusWebSample 39 | { 40 | public partial class GetSample : System.Web.UI.Page 41 | { 42 | protected void Page_Load(object sender, EventArgs e) 43 | { 44 | switch (Request.QueryString["Sample"]) 45 | { 46 | case "1": 47 | Sample1(); 48 | break; 49 | case "2": 50 | Sample2(); 51 | break; 52 | case "3": 53 | Sample3(); 54 | break; 55 | case "4": 56 | Sample4(); 57 | break; 58 | default: 59 | Response.Write(""); 60 | break; 61 | 62 | } 63 | } 64 | 65 | /// 66 | /// Sample 1 67 | /// Demonstrates the SaveAs method 68 | /// 69 | private void Sample1() 70 | { 71 | ExcelPackage pck = new ExcelPackage(); 72 | var ws = pck.Workbook.Worksheets.Add("Sample1"); 73 | 74 | ws.Cells["A1"].Value = "Sample 1"; 75 | ws.Cells["A1"].Style.Font.Bold = true; 76 | var shape = ws.Drawings.AddShape("Shape1", eShapeStyle.Rect); 77 | shape.SetPosition(50, 200); 78 | shape.SetSize(200, 100); 79 | shape.Text = "Sample 1 saves to the Response.OutputStream"; 80 | 81 | pck.SaveAs(Response.OutputStream); 82 | Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; 83 | Response.AddHeader("content-disposition", "attachment; filename=Sample1.xlsx"); 84 | } 85 | /// 86 | /// Sample 2 87 | /// Demonstrates the GetAsByteArray method 88 | /// 89 | private void Sample2() 90 | { 91 | ExcelPackage pck = new ExcelPackage(); 92 | var ws = pck.Workbook.Worksheets.Add("Sample2"); 93 | 94 | ws.Cells["A1"].Value = "Sample 2"; 95 | ws.Cells["A1"].Style.Font.Bold = true; 96 | var shape = ws.Drawings.AddShape("Shape1", eShapeStyle.Rect); 97 | shape.SetPosition(50, 200); 98 | shape.SetSize(200, 100); 99 | shape.Text = "Sample 2 outputs the sheet using the Response.BinaryWrite method"; 100 | 101 | Response.BinaryWrite(pck.GetAsByteArray()); 102 | Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; 103 | Response.AddHeader("content-disposition", "attachment; filename=Sample2.xlsx"); 104 | } 105 | /// 106 | /// Sample 3 107 | /// Uses a cached template 108 | /// 109 | private void Sample3() 110 | { 111 | if (Application["Sample3Template"] == null) //Check if the template is loaded 112 | { 113 | //Here we create the template. 114 | //As an alternative the template could be loaded from disk or from a resource. 115 | ExcelPackage pckTemplate = new ExcelPackage(); 116 | var wsTemplate = pckTemplate.Workbook.Worksheets.Add("Sample3"); 117 | 118 | wsTemplate.Cells["A1"].Value = "Sample 3"; 119 | wsTemplate.Cells["A1"].Style.Font.Bold = true; 120 | var shape = wsTemplate.Drawings.AddShape("Shape1", eShapeStyle.Rect); 121 | shape.SetPosition(50, 200); 122 | shape.SetSize(200, 100); 123 | shape.Text = "Sample 3 uses a template that is stored in the application cashe."; 124 | pckTemplate.Save(); 125 | 126 | Application["Sample3Template"] = pckTemplate.Stream; 127 | } 128 | 129 | //Open the new package with the template stream. 130 | //The template stream is copied to the new stream in the constructor 131 | ExcelPackage pck = new ExcelPackage(new MemoryStream(), Application["Sample3Template"] as Stream); 132 | var ws = pck.Workbook.Worksheets[1]; 133 | int row = new Random().Next(10) + 10; //Pick a random row to print the text 134 | ws.Cells[row,1].Value = "We make a small change here, after the template has been loaded..."; 135 | ws.Cells[row, 1, row, 5].Style.Fill.PatternType = ExcelFillStyle.Solid; 136 | ws.Cells[row, 1, row, 5].Style.Fill.BackgroundColor.SetColor(Color.LightGoldenrodYellow); 137 | 138 | Response.BinaryWrite(pck.GetAsByteArray()); 139 | Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; 140 | Response.AddHeader("content-disposition", "attachment; filename=Sample3.xlsx"); 141 | } 142 | private void Sample4() 143 | { 144 | ExcelPackage pck = new ExcelPackage(); 145 | 146 | //Add a worksheet. 147 | var ws=pck.Workbook.Worksheets.Add("VBA Sample"); 148 | ws.Drawings.AddShape("VBASampleRect", eShapeStyle.RoundRect); 149 | 150 | //Create a vba project 151 | pck.Workbook.CreateVBAProject(); 152 | 153 | //Now add some code that creates a bubble chart... 154 | var sb = new StringBuilder(); 155 | 156 | sb.AppendLine("Private Sub Workbook_Open()"); 157 | sb.AppendLine(" [VBA Sample].Shapes(\"VBASampleRect\").TextEffect.Text = \"This text is set from VBA!\""); 158 | sb.AppendLine("End Sub"); 159 | pck.Workbook.CodeModule.Code = sb.ToString(); 160 | 161 | Response.BinaryWrite(pck.GetAsByteArray()); 162 | Response.ContentType = "application/vnd.ms-excel.sheet.macroEnabled.12"; //.xlsm files uses a different contenttype than .xlsx 163 | Response.AddHeader("content-disposition", "attachment; filename=Sample4.xlsm"); 164 | 165 | } 166 | 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusWebSample/GetSample.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.4927 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EPPlusWebSample { 12 | 13 | 14 | public partial class GetSample { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusWebSample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("EPPlusWebSample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("EPPlusWebSample")] 13 | [assembly: AssemblyCopyright("Copyright © Jan Källman 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/EPPlusWebSample/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 | 8 |
9 |
10 |
11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/EPPlusSamples.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {06BF3C68-E7D4-4579-90BE-E36DACE564EF} 9 | Exe 10 | Properties 11 | EPPlusSamples 12 | EPPlusSamples 13 | 14 | 15 | 16 | 17 | 3.5 18 | false 19 | v3.5 20 | publish\ 21 | true 22 | Disk 23 | false 24 | Foreground 25 | 7 26 | Days 27 | false 28 | false 29 | true 30 | 0 31 | 1.0.0.%2a 32 | false 33 | true 34 | 35 | 36 | 37 | true 38 | full 39 | false 40 | bin\Debug\ 41 | DEBUG;TRACE 42 | prompt 43 | 4 44 | AllRules.ruleset 45 | AnyCPU 46 | 47 | 48 | pdbonly 49 | true 50 | bin\Release\ 51 | TRACE 52 | prompt 53 | 4 54 | AllRules.ruleset 55 | x86 56 | 57 | 58 | 59 | ..\Binaries\EPPlus.dll 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | False 91 | .NET Framework 3.5 SP1 Client Profile 92 | false 93 | 94 | 95 | False 96 | .NET Framework 2.0 %28x86%29 97 | true 98 | 99 | 100 | False 101 | .NET Framework 3.0 %28x86%29 102 | false 103 | 104 | 105 | False 106 | .NET Framework 3.5 107 | false 108 | 109 | 110 | False 111 | .NET Framework 3.5 SP1 112 | false 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 136 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/GraphTemplate.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/GraphTemplate.xlsx -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * You may amend and distribute as you like, but don't remove this header! 3 | * 4 | * EPPlus provides server-side generation of Excel 2007 spreadsheets. 5 | * 6 | * See http://www.codeplex.com/EPPlus for details. 7 | * 8 | * All rights reserved. 9 | * 10 | * EPPlus is an Open Source project provided under the 11 | * GNU General Public License (GPL) as published by the 12 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 13 | * 14 | * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php 15 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html 16 | * 17 | * The code for this project may be used and redistributed by any means PROVIDING it is 18 | * not sold for profit without the author's written consent, and providing that this notice 19 | * and the author's name and all copyright notices remain intact. 20 | * 21 | * All code and executables are provided "as is" with no warranty either express or implied. 22 | * The author accepts no liability for any damage or loss of business that this product may cause. 23 | * 24 | * 25 | * Code change notes: 26 | * 27 | * Author Change Date 28 | * ****************************************************************************** 29 | * Jan Källman Initial Release 2009-10-01 30 | *******************************************************************************/ 31 | using System.Reflection; 32 | using System.Runtime.CompilerServices; 33 | using System.Runtime.InteropServices; 34 | 35 | // General Information about an assembly is controlled through the following 36 | // set of attributes. Change these attribute values to modify the information 37 | // associated with an assembly. 38 | [assembly: AssemblyTitle("EPPlusSamples")] 39 | [assembly: AssemblyDescription("Demonstrate Excel files being created on the server")] 40 | [assembly: AssemblyConfiguration("")] 41 | [assembly: AssemblyCompany("")] 42 | [assembly: AssemblyProduct("EPPlus Samples")] 43 | [assembly: AssemblyTrademark("The GNU General Public License (GPL)")] 44 | [assembly: AssemblyCulture("")] 45 | 46 | // Setting ComVisible to false makes the types in this assembly not visible 47 | // to COM components. If you need to access a type in this assembly from 48 | // COM, set the ComVisible attribute to true on that type. 49 | [assembly: ComVisible(false)] 50 | 51 | // The following GUID is for the ID of the typelib if this project is exposed to COM 52 | [assembly: Guid("3795b282-73dd-47f0-accf-2197054d6cf4")] 53 | 54 | // Version information for an assembly consists of the following four values: 55 | // 56 | // Major Version 57 | // Minor Version 58 | // Build Number 59 | // Revision 60 | // 61 | [assembly: AssemblyVersion("1.0.0.1")] 62 | [assembly: AssemblyFileVersion("1.0.0.1")] 63 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample1.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample1.cs -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample13.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * You may amend and distribute as you like, but don't remove this header! 3 | * 4 | * EPPlus provides server-side generation of Excel 2007 spreadsheets. 5 | * See http://www.codeplex.com/EPPlus for details. 6 | * 7 | * All rights reserved. 8 | * 9 | * EPPlus is an Open Source project provided under the 10 | * GNU General Public License (GPL) as published by the 11 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 12 | * 13 | * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php 14 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html 15 | * 16 | * The code for this project may be used and redistributed by any means PROVIDING it is 17 | * not sold for profit without the author's written consent, and providing that this notice 18 | * and the author's name and all copyright notices remain intact. 19 | * 20 | * All code and executables are provided "as is" with no warranty either express or implied. 21 | * The author accepts no liability for any damage or loss of business that this product may cause. 22 | * 23 | * Code change notes: 24 | * 25 | * Author Change Date 26 | * ****************************************************************************** 27 | * Jan Källman Added 2011-05-03 28 | *******************************************************************************/ 29 | using System; 30 | using System.Collections.Generic; 31 | using System.Linq; 32 | using System.Text; 33 | using System.IO; 34 | using OfficeOpenXml; 35 | using System.Data; 36 | using OfficeOpenXml.Table; 37 | using System.Reflection; 38 | 39 | namespace EPPlusSamples 40 | { 41 | /// 42 | /// This class shows how to load data in a few ways 43 | /// 44 | public static class Sample13 45 | { 46 | public class FileDTO 47 | { 48 | public string Name { get; set; } 49 | public long Size {get;set;} 50 | public DateTime Created {get;set;} 51 | public DateTime LastModified {get;set;} 52 | 53 | public bool IsDirectory=false; //This is a field variable 54 | 55 | public override string ToString() 56 | { 57 | if (IsDirectory) 58 | { 59 | return Name + "\t"; 60 | } 61 | else 62 | { 63 | return Name + "\t" + Size.ToString("#,##0"); 64 | } 65 | } 66 | } 67 | 68 | public static void RunSample13(DirectoryInfo outputDir) 69 | { 70 | ExcelPackage pck = new ExcelPackage(); 71 | 72 | //Create a datatable with the directories and files from the root directory... 73 | DataTable dt = GetDataTable(outputDir.Root); 74 | 75 | var wsDt = pck.Workbook.Worksheets.Add("FromDataTable"); 76 | 77 | //Load the datatable and set the number formats... 78 | wsDt.Cells["A1"].LoadFromDataTable(dt, true, TableStyles.Medium9); 79 | wsDt.Cells[2, 2, dt.Rows.Count + 1, 2].Style.Numberformat.Format = "#,##0"; 80 | wsDt.Cells[2, 3, dt.Rows.Count + 1, 4].Style.Numberformat.Format = "mm-dd-yy"; 81 | wsDt.Cells[wsDt.Dimension.Address].AutoFitColumns(); 82 | 83 | //Select Name and Created-time... 84 | var collection = (from row in dt.Select() select new {Name=row["Name"], Created_time=(DateTime)row["Created"]}); 85 | 86 | var wsEnum = pck.Workbook.Worksheets.Add("FromAnonymous"); 87 | 88 | //Load the collection starting from cell A1... 89 | wsEnum.Cells["A1"].LoadFromCollection(collection, true, TableStyles.Medium9); 90 | 91 | //Add some formating... 92 | wsEnum.Cells[2, 2, dt.Rows.Count-1, 2].Style.Numberformat.Format = "mm-dd-yy"; 93 | wsEnum.Cells[wsEnum.Dimension.Address].AutoFitColumns(); 94 | 95 | //Load a list of FileDTO objects from the datatable... 96 | var wsList = pck.Workbook.Worksheets.Add("FromList"); 97 | List list = (from row in dt.Select() 98 | select new FileDTO { 99 | Name = row["Name"].ToString(), 100 | Size = row["Size"].GetType() == typeof(long) ? (long)row["Size"] : 0, 101 | Created = (DateTime)row["Created"], 102 | LastModified = (DateTime)row["Modified"], 103 | IsDirectory = (row["Size"]==DBNull.Value) 104 | }).ToList(); 105 | 106 | //Load files ordered by size... 107 | wsList.Cells["A1"].LoadFromCollection(from file in list 108 | orderby file.Size descending 109 | where file.IsDirectory == false 110 | select file, true, TableStyles.Medium9); 111 | 112 | wsList.Cells[2, 2, dt.Rows.Count + 1, 2].Style.Numberformat.Format = "#,##0"; 113 | wsList.Cells[2, 3, dt.Rows.Count + 1, 4].Style.Numberformat.Format = "mm-dd-yy"; 114 | 115 | 116 | //Load directories ordered by Name... 117 | wsList.Cells["F1"].LoadFromCollection(from file in list 118 | orderby file.Name ascending 119 | where file.IsDirectory == true 120 | select new { 121 | Name=file.Name, 122 | Created = file.Created, 123 | Last_modified=file.LastModified}, //Use an underscore in the property name to get a space in the title. 124 | true, TableStyles.Medium11); 125 | 126 | wsList.Cells[2, 7, dt.Rows.Count + 1, 8].Style.Numberformat.Format = "mm-dd-yy"; 127 | 128 | //Load the list using a specified array of MemberInfo objects. Properties, fields and methods are supported. 129 | var rng = wsList.Cells["J1"].LoadFromCollection(list, 130 | true, 131 | TableStyles.Medium10, 132 | BindingFlags.Instance | BindingFlags.Public, 133 | new MemberInfo[] { 134 | typeof(FileDTO).GetProperty("Name"), 135 | typeof(FileDTO).GetField("IsDirectory"), 136 | typeof(FileDTO).GetMethod("ToString")} 137 | ); 138 | 139 | wsList.Tables.GetFromRange(rng).Columns[2].Name = "Description"; 140 | 141 | wsList.Cells[wsList.Dimension.Address].AutoFitColumns(); 142 | 143 | //...and save 144 | var fi = new FileInfo(outputDir.FullName + @"\Sample13.xlsx"); 145 | if (fi.Exists) 146 | { 147 | fi.Delete(); 148 | } 149 | pck.SaveAs(fi); 150 | } 151 | 152 | private static DataTable GetDataTable(DirectoryInfo dir) 153 | { 154 | DataTable dt = new DataTable("RootDir"); 155 | dt.Columns.Add("Name", typeof(string)); 156 | dt.Columns.Add("Size", typeof(long)); 157 | dt.Columns.Add("Created", typeof(DateTime)); 158 | dt.Columns.Add("Modified", typeof(DateTime)); 159 | foreach (var item in dir.GetDirectories()) 160 | { 161 | var row=dt.NewRow(); 162 | row["Name"]=item.Name; 163 | row["Created"]=item.CreationTime; 164 | row["Modified"]=item.LastWriteTime; 165 | 166 | dt.Rows.Add(row); 167 | } 168 | foreach (var item in dir.GetFiles()) 169 | { 170 | var row = dt.NewRow(); 171 | row["Name"] = item.Name; 172 | row["Size"] = item.Length; 173 | row["Created"] = item.CreationTime; 174 | row["Modified"] = item.LastWriteTime; 175 | 176 | dt.Rows.Add(row); 177 | } 178 | return dt; 179 | } 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample16.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using OfficeOpenXml; 8 | using OfficeOpenXml.Table; 9 | 10 | namespace EPPlusSamples 11 | { 12 | class Sample16 13 | { 14 | public static void RunSample16(DirectoryInfo outputDir) 15 | { 16 | using (var package = new ExcelPackage()) 17 | { 18 | var dataTable = new DataTable("test"); 19 | dataTable.Columns.Add("col1"); 20 | dataTable.Columns.Add("col2"); 21 | dataTable.Columns.Add("col3"); 22 | dataTable.Columns.Add("col4"); 23 | dataTable.Rows.Add("qwe11", "qwe12", "qwe13", "qwe14"); 24 | dataTable.Rows.Add("qwe21", "qwe22", "qwe23", "qwe24"); 25 | ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(dataTable.TableName); 26 | worksheet.Cells["A1"].LoadFromDataTable(dataTable, true, TableStyles.None); 27 | worksheet.Protection.AllowSelectLockedCells = false; 28 | worksheet.Protection.AllowSelectUnlockedCells = true; 29 | worksheet.Protection.AllowSort = true; 30 | worksheet.Protection.AllowFormatColumns = true; 31 | worksheet.Protection.AllowAutoFilter = true; 32 | worksheet.Protection.AllowEditObject = true; 33 | worksheet.Protection.IsProtected = true; 34 | var r1=worksheet.ProtectedRanges.Add("Range1", new ExcelAddress(1, 1, worksheet.Dimension.End.Row, 4)); 35 | worksheet.ProtectedRanges.Remove(r1); 36 | var r2 = worksheet.ProtectedRanges.Add("Range2", new ExcelAddress("F3:T12,F15:T30")); 37 | r2.SetPassword("EPPlus"); 38 | 39 | worksheet.Column(1).Width = 30; 40 | worksheet.Column(2).Width = 30; 41 | worksheet.Column(3).Width = 100; 42 | worksheet.Column(4).Width = 100; 43 | worksheet.Cells[1, 4, worksheet.Dimension.End.Row, 4].Style.Locked = false; 44 | worksheet.Cells[1, 3, worksheet.Dimension.End.Row, 4].Style.WrapText = true; 45 | 46 | using (var fs = new FileStream(Path.Combine(outputDir.ToString(), "sample16.xlsx"), FileMode.Create)) 47 | package.SaveAs(fs); 48 | } 49 | 50 | using (var fs = new FileStream(Path.Combine(outputDir.ToString(), "sample16.xlsx"), FileMode.Open, FileAccess.Read)) 51 | using (var package = new ExcelPackage(fs)) 52 | { 53 | foreach (var worksheet1 in package.Workbook.Worksheets) 54 | { 55 | var prCollection = worksheet1.ProtectedRanges; 56 | if (prCollection.Count != 1) 57 | throw new InvalidOperationException("Expected 1 element"); 58 | } 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample2.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample2.cs -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample3.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample3.cs -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample4.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * You may amend and distribute as you like, but don't remove this header! 3 | * 4 | * All rights reserved. 5 | * 6 | * EPPlus is an Open Source project provided under the 7 | * GNU General Public License (GPL) as published by the 8 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 9 | * 10 | * EPPlus provides server-side generation of Excel 2007 spreadsheets. 11 | * See http://www.codeplex.com/EPPlus for details. 12 | * 13 | * 14 | * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php 15 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html 16 | * 17 | * The code for this project may be used and redistributed by any means PROVIDING it is 18 | * not sold for profit without the author's written consent, and providing that this notice 19 | * and the author's name and all copyright notices remain intact. 20 | * 21 | * All code and executables are provided "as is" with no warranty either express or implied. 22 | * The author accepts no liability for any damage or loss of business that this product may cause. 23 | * 24 | * 25 | * Code change notes: 26 | * 27 | * Author Change Date 28 | ******************************************************************************* 29 | * Jan Källman Added 10-SEP-2009 30 | *******************************************************************************/ 31 | 32 | using System; 33 | using System.Collections.Generic; 34 | using System.Text; 35 | using System.Diagnostics; 36 | using OfficeOpenXml; 37 | using System.IO; 38 | using System.Data.SqlClient; 39 | using OfficeOpenXml.Drawing; 40 | using OfficeOpenXml.Drawing.Chart; 41 | using OfficeOpenXml.Style; 42 | using System.Drawing; 43 | 44 | namespace EPPlusSamples 45 | { 46 | class Sample4 47 | { 48 | /// 49 | /// This sample creates a new workbook from a template file containing a chart and populates it with Exchangrates from 50 | /// the Adventureworks database and set the three series on the chart. 51 | /// 52 | /// Connectionstring to the Adventureworks db 53 | /// the template 54 | /// output dir 55 | /// 56 | public static string RunSample4(string connectionString, FileInfo template, DirectoryInfo outputdir) 57 | { 58 | using (ExcelPackage p = new ExcelPackage(template, true)) 59 | { 60 | //Set up the headers 61 | ExcelWorksheet ws = p.Workbook.Worksheets[1]; 62 | ws.Cells["A20"].Value = "Date"; 63 | ws.Cells["B20"].Value = "EOD Rate"; 64 | ws.Cells["B20:D20"].Merge = true; 65 | ws.Cells["E20"].Value = "Change"; 66 | ws.Cells["E20:G20"].Merge = true; 67 | ws.Cells["B20:E20"].Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous; 68 | using (ExcelRange row = ws.Cells["A20:G20"]) 69 | { 70 | row.Style.Fill.PatternType = ExcelFillStyle.Solid; 71 | row.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(23,55,93)); 72 | row.Style.Font.Color.SetColor(Color.White); 73 | row.Style.Font.Bold = true; 74 | } 75 | ws.Cells["B21"].Value = "USD/JPY"; 76 | ws.Cells["C21"].Value = "USD/EUR"; 77 | ws.Cells["D21"].Value = "USD/GBP"; 78 | ws.Cells["E21"].Value = "USD/JPY"; 79 | ws.Cells["F21"].Value = "USD/EUR"; 80 | ws.Cells["G21"].Value = "USD/GBP"; 81 | using (ExcelRange row = ws.Cells["A21:G21"]) 82 | { 83 | row.Style.Fill.PatternType = ExcelFillStyle.Solid; 84 | row.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(184, 204, 228)); 85 | row.Style.Font.Color.SetColor(Color.Black); 86 | row.Style.Font.Bold = true; 87 | } 88 | 89 | int startRow = 22; 90 | //Connect to the database and fill the data 91 | using (SqlConnection sqlConn = new SqlConnection(connectionString)) 92 | { 93 | int row = startRow; 94 | sqlConn.Open(); 95 | using (SqlCommand sqlCmd = new SqlCommand("SELECT CurrencyRateDate, SUM(Case when ToCurrencyCode = 'JPY' Then EndOfDayRate Else 0 END) AS [JPY], SUM(Case when ToCurrencyCode = 'EUR' Then EndOfDayRate Else 0 END) AS [EUR], SUM(Case when ToCurrencyCode = 'GBP' Then EndOfDayRate Else 0 END) AS [GBP] FROM [AdventureWorks].[Sales].[CurrencyRate] where [FromCurrencyCode]='USD' AND ToCurrencyCode in ('JPY', 'EUR', 'GBP') GROUP BY CurrencyRateDate ORDER BY CurrencyRateDate", sqlConn)) 96 | { 97 | using (SqlDataReader sqlReader = sqlCmd.ExecuteReader()) 98 | { 99 | // get the data and fill rows 22 onwards 100 | while (sqlReader.Read()) 101 | { 102 | ws.Cells[row, 1].Value = sqlReader[0]; 103 | ws.Cells[row, 2].Value = sqlReader[1]; 104 | ws.Cells[row, 3].Value = sqlReader[2]; 105 | ws.Cells[row, 4].Value = sqlReader[3]; 106 | row++; 107 | } 108 | } 109 | //Set the numberformat 110 | ws.Cells[startRow, 1, row - 1, 1].Style.Numberformat.Format = "yyyy-mm-dd"; 111 | ws.Cells[startRow, 2, row - 1, 4].Style.Numberformat.Format = "#,##0.0000"; 112 | //Set the Formulas 113 | ws.Cells[startRow + 1, 5, row - 1, 7].Formula = string.Format("B${0}/B{1}-1", startRow, startRow + 1); 114 | ws.Cells[startRow, 5, row - 1, 7].Style.Numberformat.Format = "0.00%"; 115 | } 116 | 117 | //Set the series for the chart. The series must exist in the template or the program will crash. 118 | ExcelChart chart = ((ExcelChart)ws.Drawings["SampleChart"]); 119 | chart.Title.Text = "Exchange rate %"; 120 | chart.Series[0].Header = "USD/JPY"; 121 | chart.Series[0].XSeries = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow+1, 1, row - 1, 1); 122 | chart.Series[0].Series = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 5, row - 1, 5); 123 | 124 | chart.Series[1].Header = "USD/EUR"; 125 | chart.Series[1].XSeries = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 1, row - 1, 1); 126 | chart.Series[1].Series = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 6, row - 1, 6); 127 | 128 | chart.Series[2].Header = "USD/GBP"; 129 | chart.Series[2].XSeries = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 1, row - 1, 1); 130 | chart.Series[2].Series = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 7, row - 1, 7); 131 | } 132 | //Get the documet as a byte array from the stream and save it to disk. (This is usefull in a webapplication) ... 133 | Byte[] bin = p.GetAsByteArray(); 134 | 135 | string file = outputdir + "\\sample4.xlsx"; 136 | File.WriteAllBytes(file, bin); 137 | return file; 138 | } 139 | } 140 | } 141 | } -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample5.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * You may amend and distribute as you like, but don't remove this header! 3 | * 4 | * All rights reserved. 5 | * 6 | * EPPlus is an Open Source project provided under the 7 | * GNU General Public License (GPL) as published by the 8 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 9 | * 10 | * EPPlus provides server-side generation of Excel 2007 spreadsheets. 11 | * See http://www.codeplex.com/EPPlus for details. 12 | * 13 | * 14 | * 15 | * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php 16 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html 17 | * 18 | * The code for this project may be used and redistributed by any means PROVIDING it is 19 | * not sold for profit without the author's written consent, and providing that this notice 20 | * and the author's name and all copyright notices remain intact. 21 | * 22 | * All code and executables are provided "as is" with no warranty either express or implied. 23 | * The author accepts no liability for any damage or loss of business that this product may cause. 24 | * 25 | * 26 | * Code change notes: 27 | * 28 | * Author Change Date 29 | ******************************************************************************* 30 | * Jan Källman Added 07-JAN-2010 31 | *******************************************************************************/ 32 | using System; 33 | using System.Collections.Generic; 34 | using System.Text; 35 | using System.IO; 36 | using OfficeOpenXml; 37 | using OfficeOpenXml.Drawing.Chart; 38 | using OfficeOpenXml.Drawing; 39 | using System.Drawing; 40 | 41 | namespace EPPlusSamples 42 | { 43 | class Sample5 44 | { 45 | /// 46 | /// Sample 5 - open Sample 1 and add 2 new rows and a Piechart 47 | /// 48 | public static string RunSample5(DirectoryInfo outputDir) 49 | { 50 | FileInfo templateFile = new FileInfo(outputDir.FullName + @"\sample1.xlsx"); 51 | FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample5.xlsx"); 52 | if (newFile.Exists) 53 | { 54 | newFile.Delete(); // ensures we create a new workbook 55 | newFile = new FileInfo(outputDir.FullName + @"\sample5.xlsx"); 56 | } 57 | using (ExcelPackage package = new ExcelPackage(newFile, templateFile)) 58 | { 59 | //Open worksheet 1 60 | ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; 61 | worksheet.InsertRow(5, 2); 62 | 63 | worksheet.Cells["A5"].Value = "12010"; 64 | worksheet.Cells["B5"].Value = "Drill"; 65 | worksheet.Cells["C5"].Value = 20; 66 | worksheet.Cells["D5"].Value = 8; 67 | 68 | worksheet.Cells["A6"].Value = "12011"; 69 | worksheet.Cells["B6"].Value = "Crowbar"; 70 | worksheet.Cells["C6"].Value = 7; 71 | worksheet.Cells["D6"].Value = 23.48; 72 | 73 | worksheet.Cells["E2:E6"].FormulaR1C1 = "RC[-2]*RC[-1]"; 74 | 75 | var name = worksheet.Names.Add("SubTotalName", worksheet.Cells["C7:E7"]); 76 | name.Style.Font.Italic = true; 77 | name.Formula = "SUBTOTAL(9,C2:C6)"; 78 | 79 | //Format the new rows 80 | worksheet.Cells["C5:C6"].Style.Numberformat.Format = "#,##0"; 81 | worksheet.Cells["D5:E6"].Style.Numberformat.Format = "#,##0.00"; 82 | 83 | var chart = (worksheet.Drawings.AddChart("PieChart", eChartType.Pie3D) as ExcelPieChart); 84 | 85 | chart.Title.Text = "Total"; 86 | //From row 1 colum 5 with five pixels offset 87 | chart.SetPosition(0, 0, 5, 5); 88 | chart.SetSize(600, 300); 89 | 90 | ExcelAddress valueAddress = new ExcelAddress(2, 5, 6, 5); 91 | var ser = (chart.Series.Add(valueAddress.Address, "B2:B6") as ExcelPieChartSerie); 92 | chart.DataLabel.ShowCategory = true; 93 | chart.DataLabel.ShowPercent = true; 94 | 95 | chart.Legend.Border.LineStyle = eLineStyle.Solid; 96 | chart.Legend.Border.Fill.Style = eFillStyle.SolidFill; 97 | chart.Legend.Border.Fill.Color = Color.DarkBlue; 98 | 99 | //Switch the PageLayoutView back to normal 100 | worksheet.View.PageLayoutView = false; 101 | // save our new workbook and we are done! 102 | package.Save(); 103 | } 104 | 105 | return newFile.FullName; 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample7.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using OfficeOpenXml; 6 | using OfficeOpenXml.Style; 7 | using System.Drawing; 8 | namespace EPPlusSamples 9 | { 10 | class Sample7 11 | { 12 | /// 13 | /// This sample load a number of rows, style them and insert a row at the top. 14 | /// A password is set to protect locked cells. Column 3 & 4 will be editable, the rest will be locked. 15 | /// 16 | /// 17 | /// 18 | public static string RunSample7(DirectoryInfo outputDir, int Rows) 19 | { 20 | FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample7.xlsx"); 21 | if (newFile.Exists) 22 | { 23 | newFile.Delete(); // ensures we create a new workbook 24 | newFile = new FileInfo(outputDir.FullName + @"\sample7.xlsx"); 25 | } 26 | 27 | using (ExcelPackage package = new ExcelPackage()) 28 | { 29 | Console.WriteLine("{0:HH.mm.ss}\tStarting...", DateTime.Now); 30 | 31 | //Load the sheet with one string column, one date column and a few random numbers. 32 | var ws = package.Workbook.Worksheets.Add("Performance Test"); 33 | 34 | //Format all cells 35 | ExcelRange cols = ws.Cells["A:XFD"]; 36 | cols.Style.Fill.PatternType = ExcelFillStyle.Solid; 37 | cols.Style.Fill.BackgroundColor.SetColor(Color.LightGray); 38 | 39 | var rnd = new Random(); 40 | for (int row = 1; row <= Rows; row++) 41 | { 42 | ws.SetValue(row, 1, row); //The SetValue method is a little bit faster than using the Value property 43 | ws.SetValue(row, 2, string.Format("Row {0}", row)); 44 | ws.SetValue(row, 3, DateTime.Today.AddDays(row)); 45 | ws.SetValue(row, 4, rnd.NextDouble() * 10000); 46 | if (row % 10000 == 0) 47 | { 48 | Console.WriteLine("{0:HH.mm.ss}\tWriting row {1}...", DateTime.Now, row); 49 | } 50 | } 51 | ws.Cells[1, 5, Rows, 5].FormulaR1C1 = "RC[-4]+RC[-1]"; 52 | 53 | //Add a sum at the end 54 | ws.Cells[Rows + 1, 5].Formula = string.Format("Sum({0})", new ExcelAddress(1, 5, Rows, 5).Address); 55 | ws.Cells[Rows + 1, 5].Style.Font.Bold = true; 56 | ws.Cells[Rows + 1, 5].Style.Numberformat.Format = "#,##0.00"; 57 | 58 | Console.WriteLine("{0:HH.mm.ss}\tWriting row {1}...", DateTime.Now, Rows); 59 | Console.WriteLine("{0:HH.mm.ss}\tFormatting...", DateTime.Now); 60 | //Format the date and numeric columns 61 | ws.Cells[1, 1, Rows, 1].Style.Numberformat.Format = "#,##0"; 62 | ws.Cells[1, 3, Rows, 3].Style.Numberformat.Format = "YYYY-MM-DD"; 63 | ws.Cells[1, 4, Rows, 5].Style.Numberformat.Format = "#,##0.00"; 64 | 65 | Console.WriteLine("{0:HH.mm.ss}\tInsert a row at the top...", DateTime.Now); 66 | //Insert a row at the top. Note that the formula-addresses are shifted down 67 | ws.InsertRow(1, 1); 68 | 69 | //Write the headers and style them 70 | ws.Cells["A1"].Value = "Index"; 71 | ws.Cells["B1"].Value = "Text"; 72 | ws.Cells["C1"].Value = "Date"; 73 | ws.Cells["D1"].Value = "Number"; 74 | ws.Cells["E1"].Value = "Formula"; 75 | ws.View.FreezePanes(2, 1); 76 | 77 | using (var rng = ws.Cells["A1:E1"]) 78 | { 79 | rng.Style.Font.Bold = true; 80 | rng.Style.Font.Color.SetColor(Color.White); 81 | rng.Style.WrapText = true; 82 | rng.Style.VerticalAlignment = ExcelVerticalAlignment.Center; 83 | rng.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; 84 | rng.Style.Fill.PatternType = ExcelFillStyle.Solid; 85 | rng.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue); 86 | } 87 | 88 | //Calculate (Commented away thisk, it was a bit time consuming... /MA) 89 | // Console.WriteLine("{0:HH.mm.ss}\tCalculate formulas...", DateTime.Now); 90 | // ws.Calculate(); 91 | 92 | Console.WriteLine("{0:HH.mm.ss}\tAutofit columns and lock and format cells...", DateTime.Now); 93 | ws.Cells[Rows - 100, 1, Rows, 5].AutoFitColumns(5); //Auto fit using the last 100 rows with minimum width 5 94 | ws.Column(5).Width = 15; //We need to set the width for column F manually since the end sum formula is the widest cell in the column (EPPlus don't calculate any forumlas, so no output text is avalible). 95 | 96 | //Now we set the sheetprotection and a password. 97 | ws.Cells[2, 3, Rows + 1, 4].Style.Locked = false; 98 | ws.Cells[2, 3, Rows + 1, 4].Style.Fill.PatternType = ExcelFillStyle.Solid; 99 | ws.Cells[2, 3, Rows + 1, 4].Style.Fill.BackgroundColor.SetColor(Color.White); 100 | ws.Cells[1, 5, Rows + 2, 5].Style.Hidden = true; //Hide the formula 101 | 102 | ws.Protection.SetPassword("EPPlus"); 103 | 104 | ws.Select("C2"); 105 | Console.WriteLine("{0:HH.mm.ss}\tSaving...", DateTime.Now); 106 | package.Compression = CompressionLevel.BestSpeed; 107 | package.SaveAs(newFile); 108 | } 109 | Console.WriteLine("{0:HH.mm.ss}\tDone!!", DateTime.Now); 110 | return newFile.FullName; 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample8.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * You may amend and distribute as you like, but don't remove this header! 3 | * 4 | * All rights reserved. 5 | * 6 | * EPPlus is an Open Source project provided under the 7 | * GNU General Public License (GPL) as published by the 8 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 9 | * 10 | * EPPlus provides server-side generation of Excel 2007 spreadsheets. 11 | * See http://www.codeplex.com/EPPlus for details. 12 | * 13 | * 14 | * 15 | * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php 16 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html 17 | * 18 | * The code for this project may be used and redistributed by any means PROVIDING it is 19 | * not sold for profit without the author's written consent, and providing that this notice 20 | * and the author's name and all copyright notices remain intact. 21 | * 22 | * All code and executables are provided "as is" with no warranty either express or implied. 23 | * The author accepts no liability for any damage or loss of business that this product may cause. 24 | * 25 | * 26 | * Code change notes: 27 | * 28 | * Author Change Date 29 | ******************************************************************************* 30 | * Jan Källman Added 21 Mar 2010 31 | *******************************************************************************/ 32 | using System; 33 | using System.Collections.Generic; 34 | using System.Text; 35 | using System.IO; 36 | using OfficeOpenXml; 37 | using System.Xml; 38 | using System.Drawing; 39 | using OfficeOpenXml.Style; 40 | using System.Linq; 41 | namespace EPPlusSamples 42 | { 43 | public static class LinqSample 44 | { 45 | /// 46 | /// This sample shows how to use Linq with the Cells collection 47 | /// 48 | /// The path where sample7.xlsx is 49 | public static void RunLinqSample(DirectoryInfo outputDir) 50 | { 51 | Console.WriteLine("Now open sample 7 again and perform some Linq queries..."); 52 | Console.WriteLine(); 53 | 54 | FileInfo existingFile = new FileInfo(outputDir.FullName + @"\sample7.xlsx"); 55 | using (ExcelPackage package = new ExcelPackage(existingFile)) 56 | { 57 | ExcelWorksheet sheet = package.Workbook.Worksheets[1]; 58 | 59 | //Select all cells in column d between 9990 and 10000 60 | var query1= (from cell in sheet.Cells["d:d"] where cell.Value is double && (double)cell.Value >= 9990 && (double)cell.Value <= 10000 select cell); 61 | 62 | Console.WriteLine("Print all cells with value between 9990 and 10000 in column D ..."); 63 | Console.WriteLine(); 64 | 65 | int count = 0; 66 | foreach (var cell in query1) 67 | { 68 | Console.WriteLine("Cell {0} has value {1:N0}", cell.Address, cell.Value); 69 | count++; 70 | } 71 | 72 | Console.WriteLine("{0} cells found ...",count); 73 | Console.WriteLine(); 74 | 75 | //Select all bold cells 76 | Console.WriteLine("Now get all bold cells from the entire sheet..."); 77 | var query2 = (from cell in sheet.Cells[sheet.Dimension.Address] where cell.Style.Font.Bold select cell); 78 | //If you have a clue where the data is, specify a smaller range in the cells indexer to get better performance (for example "1:1,65536:65536" here) 79 | count = 0; 80 | foreach (var cell in query2) 81 | { 82 | if (!string.IsNullOrEmpty(cell.Formula)) 83 | { 84 | Console.WriteLine("Cell {0} is bold and has a formula of {1:N0}", cell.Address, cell.Formula); 85 | } 86 | else 87 | { 88 | Console.WriteLine("Cell {0} is bold and has a value of {1:N0}", cell.Address, cell.Value); 89 | } 90 | count++; 91 | } 92 | 93 | //Here we use more than one column in the where clause. We start by searching column D, then use the Offset method to check the value of column C. 94 | var query3 = (from cell in sheet.Cells["d:d"] 95 | where cell.Value is double && 96 | (double)cell.Value >= 9500 && (double)cell.Value <= 10000 && 97 | cell.Offset(0, -1).GetValue().Year == DateTime.Today.Year+1 98 | select cell); 99 | 100 | Console.WriteLine(); 101 | Console.WriteLine("Print all cells with a value between 9500 and 10000 in column D and the year of Column C is {0} ...", DateTime.Today.Year + 1); 102 | Console.WriteLine(); 103 | 104 | count = 0; 105 | foreach (var cell in query3) //The cells returned here will all be in column D, since that is the address in the indexer. Use the Offset method to print any other cells from the same row. 106 | { 107 | Console.WriteLine("Cell {0} has value {1:N0} Date is {2:d}", cell.Address, cell.Value, cell.Offset(0, -1).GetValue()); 108 | count++; 109 | } 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample9.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * You may amend and distribute as you like, but don't remove this header! 3 | * 4 | * All rights reserved. 5 | * 6 | * EPPlus is an Open Source project provided under the 7 | * GNU General Public License (GPL) as published by the 8 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 9 | * 10 | * EPPlus provides server-side generation of Excel 2007 spreadsheets. 11 | * See http://www.codeplex.com/EPPlus for details. 12 | * 13 | * 14 | * 15 | * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php 16 | * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html 17 | * 18 | * The code for this project may be used and redistributed by any means PROVIDING it is 19 | * not sold for profit without the author's written consent, and providing that this notice 20 | * and the author's name and all copyright notices remain intact. 21 | * 22 | * All code and executables are provided "as is" with no warranty either express or implied. 23 | * The author accepts no liability for any damage or loss of business that this product may cause. 24 | * 25 | * 26 | * Code change notes: 27 | * 28 | * Author Change Date 29 | ******************************************************************************* 30 | * Jan Källman Added 28 Oct 2010 31 | *******************************************************************************/ 32 | using System; 33 | using System.Collections.Generic; 34 | using System.Linq; 35 | using System.Text; 36 | using OfficeOpenXml; 37 | using System.IO; 38 | using OfficeOpenXml.Table; 39 | using OfficeOpenXml.Drawing.Chart; 40 | using System.Globalization; 41 | namespace EPPlusSamples 42 | { 43 | /// 44 | /// This sample shows how to load CSV files using the LoadFromText method, how to use tables and 45 | /// how to use charts with more than one charttype and secondary axis 46 | /// 47 | public static class Sample9 48 | { 49 | /// 50 | /// Loads two CSV files into tables and adds a chart to each sheet. 51 | /// 52 | /// 53 | /// 54 | public static string RunSample9(DirectoryInfo outputDir) 55 | { 56 | FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample9.xlsx"); 57 | if (newFile.Exists) 58 | { 59 | newFile.Delete(); // ensures we create a new workbook 60 | newFile = new FileInfo(outputDir.FullName + @"\sample9.xlsx"); 61 | } 62 | 63 | using (ExcelPackage package = new ExcelPackage()) 64 | { 65 | LoadFile1(package); 66 | LoadFile2(package); 67 | 68 | package.SaveAs(newFile); 69 | } 70 | return newFile.FullName; 71 | } 72 | private static void LoadFile1(ExcelPackage package) 73 | { 74 | //Create the Worksheet 75 | var sheet = package.Workbook.Worksheets.Add("Csv1"); 76 | 77 | //Create the format object to describe the text file 78 | var format = new ExcelTextFormat(); 79 | format.TextQualifier = '"'; 80 | format.SkipLinesBeginning = 2; 81 | format.SkipLinesEnd = 1; 82 | 83 | //Now read the file into the sheet. Start from cell A1. Create a table with style 27. First row contains the header. 84 | Console.WriteLine("Load the text file..."); 85 | var range = sheet.Cells["A1"].LoadFromText(new FileInfo("..\\..\\csv\\Sample9-1.txt"), format, TableStyles.Medium27, true); 86 | 87 | Console.WriteLine("Format the table..."); 88 | //Tables don't support custom styling at this stage(you can of course format the cells), but we can create a Namedstyle for a column... 89 | var dateStyle = package.Workbook.Styles.CreateNamedStyle("TableDate"); 90 | dateStyle.Style.Numberformat.Format = "YYYY-MM"; 91 | 92 | var numStyle = package.Workbook.Styles.CreateNamedStyle("TableNumber"); 93 | numStyle.Style.Numberformat.Format = "#,##0.0"; 94 | 95 | //Now format the table... 96 | var tbl = sheet.Tables[0]; 97 | tbl.ShowTotal = true; 98 | tbl.Columns[0].TotalsRowLabel = "Total"; 99 | tbl.Columns[0].DataCellStyleName = "TableDate"; 100 | tbl.Columns[1].TotalsRowFunction = RowFunctions.Sum; 101 | tbl.Columns[1].DataCellStyleName = "TableNumber"; 102 | tbl.Columns[2].TotalsRowFunction = RowFunctions.Sum; 103 | tbl.Columns[2].DataCellStyleName = "TableNumber"; 104 | tbl.Columns[3].TotalsRowFunction = RowFunctions.Sum; 105 | tbl.Columns[3].DataCellStyleName = "TableNumber"; 106 | tbl.Columns[4].TotalsRowFunction = RowFunctions.Sum; 107 | tbl.Columns[4].DataCellStyleName = "TableNumber"; 108 | tbl.Columns[5].TotalsRowFunction = RowFunctions.Sum; 109 | tbl.Columns[5].DataCellStyleName = "TableNumber"; 110 | tbl.Columns[6].TotalsRowFunction = RowFunctions.Sum; 111 | tbl.Columns[6].DataCellStyleName = "TableNumber"; 112 | 113 | Console.WriteLine("Create the chart..."); 114 | //Now add a stacked areachart... 115 | var chart = sheet.Drawings.AddChart("chart1", eChartType.AreaStacked); 116 | chart.SetPosition(0, 630); 117 | chart.SetSize(800, 600); 118 | 119 | //Create one series for each column... 120 | for (int col = 1; col < 7; col++) 121 | { 122 | var ser = chart.Series.Add(range.Offset(1, col, range.End.Row - 1, 1), range.Offset(1, 0, range.End.Row - 1, 1)); 123 | ser.HeaderAddress = range.Offset(0, col, 1, 1); 124 | } 125 | 126 | //Set the style to 27. 127 | chart.Style = eChartStyle.Style27; 128 | 129 | sheet.View.ShowGridLines = false; 130 | sheet.Calculate(); 131 | sheet.Cells[sheet.Dimension.Address].AutoFitColumns(); 132 | } 133 | 134 | private static void LoadFile2(ExcelPackage package) 135 | { 136 | //Create the Worksheet 137 | var sheet = package.Workbook.Worksheets.Add("Csv2"); 138 | 139 | //Create the format object to describe the text file 140 | var format = new ExcelTextFormat(); 141 | format.Delimiter='\t'; //Tab 142 | format.SkipLinesBeginning = 1; 143 | CultureInfo ci = new CultureInfo("sv-SE"); //Use your choice of Culture 144 | ci.NumberFormat.NumberDecimalSeparator = ","; //Decimal is comma 145 | format.Culture = ci; 146 | 147 | //Now read the file into the sheet. 148 | Console.WriteLine("Load the text file..."); 149 | var range = sheet.Cells["A1"].LoadFromText(new FileInfo("..\\..\\csv\\Sample9-2.txt"), format); 150 | 151 | //Add a formula 152 | range.Offset(1, range.End.Column, range.End.Row - range.Start.Row, 1).FormulaR1C1 = "RC[-1]-RC[-2]"; 153 | 154 | //Add a table... 155 | var tbl = sheet.Tables.Add(range.Offset(0,0,range.End.Row-range.Start.Row+1, range.End.Column-range.Start.Column+2),"Table"); 156 | tbl.ShowTotal = true; 157 | tbl.Columns[0].TotalsRowLabel = "Total"; 158 | tbl.Columns[1].TotalsRowFormula = "COUNT(3,Table[Product])"; //Add a custom formula 159 | tbl.Columns[2].TotalsRowFunction = RowFunctions.Sum; 160 | tbl.Columns[3].TotalsRowFunction = RowFunctions.Sum; 161 | tbl.Columns[4].TotalsRowFunction = RowFunctions.Sum; 162 | tbl.Columns[5].TotalsRowFunction = RowFunctions.Sum; 163 | tbl.Columns[5].Name = "Profit"; 164 | tbl.TableStyle = TableStyles.Medium10; 165 | 166 | sheet.Cells[sheet.Dimension.Address].AutoFitColumns(); 167 | 168 | //Add a chart with two charttypes (Column and Line) and a secondary axis... 169 | var chart = sheet.Drawings.AddChart("chart2", eChartType.ColumnStacked); 170 | chart.SetPosition(0, 540); 171 | chart.SetSize(800, 600); 172 | 173 | var serie1= chart.Series.Add(range.Offset(1, 3, range.End.Row - 1, 1), range.Offset(1, 1, range.End.Row - 1, 1)); 174 | serie1.Header = "Purchase Price"; 175 | var serie2 = chart.Series.Add(range.Offset(1, 5, range.End.Row - 1, 1), range.Offset(1, 1, range.End.Row - 1, 1)); 176 | serie2.Header = "Profit"; 177 | 178 | //Add a Line series 179 | var chartType2 = chart.PlotArea.ChartTypes.Add(eChartType.LineStacked); 180 | chartType2.UseSecondaryAxis = true; 181 | var serie3 = chartType2.Series.Add(range.Offset(1, 2, range.End.Row - 1, 1), range.Offset(1, 0, range.End.Row - 1, 1)); 182 | serie3.Header = "Items in stock"; 183 | 184 | //By default the secondary XAxis is not visible, but we want to show it... 185 | chartType2.XAxis.Deleted = false; 186 | chartType2.XAxis.TickLabelPosition = eTickLabelPosition.High; 187 | 188 | //Set the max value for the Y axis... 189 | chartType2.YAxis.MaxValue = 50; 190 | 191 | chart.Style = eChartStyle.Style26; 192 | sheet.View.ShowGridLines = false; 193 | sheet.Calculate(); 194 | } 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample_AddFormulaFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using OfficeOpenXml; 7 | using OfficeOpenXml.FormulaParsing; 8 | using OfficeOpenXml.FormulaParsing.Excel.Functions; 9 | using OfficeOpenXml.FormulaParsing.ExpressionGraph; 10 | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; 11 | 12 | namespace EPPlusSamples 13 | { 14 | /// 15 | /// This sample shows how to add functions to the FormulaParser of EPPlus. 16 | /// 17 | /// For further details on how to build functions, have a look in the EPPlus.FormulaParsing.Excel.Functions namespace 18 | /// 19 | class Sample_AddFormulaFunction 20 | { 21 | public static void RunSample_AddFormulaFunction() 22 | { 23 | using (var package = new ExcelPackage(new MemoryStream())) 24 | { 25 | // add your function module to the parser 26 | package.Workbook.FormulaParserManager.LoadFunctionModule(new MyFunctionModule()); 27 | 28 | // Note that if you dont want to write a module, you can also 29 | // add new functions to the parser this way: 30 | // package.Workbook.FormulaParserManager.AddOrReplaceFunction("sum.addtwo", new SumAddTwo());- 31 | // package.Workbook.FormulaParserManager.AddOrReplaceFunction("seanconneryfy", new SeanConneryfy()); 32 | 33 | 34 | //Override the buildin Text function to handle swedish date formatting strings. Excel has localized date format strings with is now supported by EPPlus. 35 | package.Workbook.FormulaParserManager.AddOrReplaceFunction("text", new TextSwedish()); 36 | 37 | // add a worksheet with some dummy data 38 | var ws = package.Workbook.Worksheets.Add("Test"); 39 | ws.Cells["A1"].Value = 1; 40 | ws.Cells["A2"].Value = 2; 41 | ws.Cells["P3"].Formula = "SUM(A1:A2)"; 42 | ws.Cells["B1"].Value = "Hello"; 43 | ws.Cells["C1"].Value = new DateTime(2013,12,31); 44 | ws.Cells["C2"].Formula="Text(C1,\"åååå-MM-dd\")"; //Swedish formatting 45 | // use the added "sum.addtwo" function 46 | ws.Cells["A4"].Formula = "SUM.ADDTWO(A1:A2,P3)"; 47 | // use the other function "seanconneryfy" 48 | ws.Cells["B2"].Formula = "seanconneryfy(B1)"; 49 | 50 | // calculate 51 | ws.Calculate(); 52 | 53 | // show result 54 | Console.WriteLine("sum.addtwo(A1:A2,P3) evaluated to {0}", ws.Cells["A4"].Value); 55 | Console.WriteLine("seanconneryfy(B1) evaluated to {0}", ws.Cells["B2"].Value); 56 | } 57 | } 58 | } 59 | 60 | class MyFunctionModule : IFunctionModule 61 | { 62 | public MyFunctionModule() 63 | { 64 | Functions = new Dictionary() 65 | { 66 | {"sum.addtwo", new SumAddTwo()}, 67 | {"seanconneryfy", new SeanConneryfy()} 68 | }; 69 | } 70 | 71 | public IDictionary Functions { get; private set; } 72 | } 73 | 74 | /// 75 | /// A really unnecessary function. Adds two to all numbers in the supplied range and calculates the sum. 76 | /// 77 | class SumAddTwo : ExcelFunction 78 | { 79 | public override CompileResult Execute(IEnumerable arguments, ParsingContext context) 80 | { 81 | // Sanity check, will set excel VALUE error if min length is not met 82 | ValidateArguments(arguments, 1); 83 | 84 | // Helper method that converts function arguments to an enumerable of doubles 85 | var numbers = ArgsToDoubleEnumerable(arguments, context); 86 | 87 | // Do the work 88 | var result = 0d; 89 | numbers.ToList().ForEach(x => result += (x + 2)); 90 | 91 | // return the result 92 | return CreateResult(result, DataType.Decimal); 93 | } 94 | } 95 | /// 96 | /// This function handles Swedish formatting strings. 97 | /// 98 | class TextSwedish : ExcelFunction 99 | { 100 | public override CompileResult Execute(IEnumerable arguments, ParsingContext context) 101 | { 102 | // Sanity check, will set excel VALUE error if min length is not met 103 | ValidateArguments(arguments, 2); 104 | 105 | //Replace swedish year format with invariant for parameter 2. 106 | var format = arguments.ElementAt(1).Value.ToString().Replace("åååå", "yyyy"); 107 | var newArgs = new List { arguments.ElementAt(0) }; 108 | newArgs.Add(new FunctionArgument(format)); 109 | 110 | //Use the build-in Text function. 111 | var func = new Text(); 112 | return func.Execute(newArgs, context); 113 | } 114 | } 115 | 116 | /// 117 | /// An even more unnecessary function, inspired by the Sean Connery keyboard;) Will add 'sh' at the end of the supplied string. 118 | /// 119 | class SeanConneryfy : ExcelFunction 120 | { 121 | public override CompileResult Execute(IEnumerable arguments, ParsingContext context) 122 | { 123 | // Sanity check, will set excel VALUE error if min length is not met 124 | ValidateArguments(arguments, 1); 125 | // Get the first arg 126 | var input = ArgToString(arguments, 0); 127 | 128 | // return the result 129 | return CreateResult(input + "sh", DataType.String); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/Sample_FormulaCalc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using OfficeOpenXml; 7 | 8 | namespace EPPlusSamples 9 | { 10 | class Sample_FormulaCalc 11 | { 12 | public static void RunSampleFormulaCalc() 13 | { 14 | using (var package = new ExcelPackage(new MemoryStream())) 15 | { 16 | var ws1 = package.Workbook.Worksheets.Add("ws1"); 17 | // Add some values to sum 18 | ws1.Cells["A1"].Formula = "(2*2)/2"; 19 | ws1.Cells["A2"].Value = 4; 20 | ws1.Cells["A3"].Value = 6; 21 | ws1.Cells["A4"].Formula = "SUM(A1:A3)"; 22 | 23 | // calculate all formulas on the worksheet 24 | ws1.Calculate(); 25 | 26 | // Print the calculated value 27 | Console.WriteLine("SUM(A1:A3) evaluated to {0}", ws1.Cells["A4"].Value); 28 | 29 | // Add another worksheet 30 | var ws2 = package.Workbook.Worksheets.Add("ws2"); 31 | ws2.Cells["A1"].Value = 3; 32 | ws2.Cells["A2"].Formula = "SUM(A1,ws1!A4)"; 33 | 34 | // calculate all formulas in the entire workbook 35 | package.Workbook.Calculate(); 36 | 37 | // Print the calculated value 38 | Console.WriteLine("SUM(A1,ws1!A4) evaluated to {0}", ws2.Cells["A2"].Value); 39 | 40 | // calculate a range 41 | ws1.Cells["B1"].Formula = "IF(TODAY() xlMedium Then 11 | SetHit Target 12 | Dim Ship 13 | Dim isHit As Boolean 14 | isHit = False 15 | For Each Ship In g_Ships 16 | If Ship.isHit(Target.Cells(1, 1), True) Then 17 | If CheckWinner(g_Ships) Then 18 | MsgBox "You win!", vbOKOnly + vbExclamation, "Battleships" 19 | g_gameEnded = True 20 | Cancel = True 21 | Exit Sub 22 | End If 23 | isHit = True 24 | Exit For 25 | End If 26 | Next 27 | If isHit = False Then 28 | Unprotect 29 | Battleship.Cells(g_logRow, 2).value = "You get a miss on " & Target.Address 30 | Battleship.Names("PlayerMisses").RefersToRange.value = Battleship.Names("PlayerMisses").RefersToRange.value + 1 31 | g_logRow = g_logRow + 1 32 | Protect "" 33 | End If 34 | ComputerPlay.Move 35 | 36 | End If 37 | End If 38 | Cancel = True 39 | End Sub 40 | Private Sub Worksheet_SelectionChange(ByVal Target As Range) 41 | Target.Cells(1, 1).Select 42 | End Sub 43 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/VBA-Code/CodeModule.txt: -------------------------------------------------------------------------------- 1 | Public Const board1 = "{5}" 2 | Public Const board2 = "{6}" 3 | 4 | Public Const userShip1 = "{0}" 5 | Public Const userShip2 = "{1}" 6 | Public Const userShip3 = "{2}" 7 | Public Const userShip4 = "{3}" 8 | Public Const userShip5 = "{4}" 9 | 10 | Global g_logRow As Integer 11 | Global g_gameEnded As Boolean 12 | Global g_Ships As Collection 13 | Global g_userShips As Collection 14 | Public Function Collide(r1 As Range, r2 As Range) As Boolean 15 | If r1.row + r1.Rows.Count > r2.row And r1.row < r2.row + r2.Rows.Count And _ 16 | r1.column + r1.Columns.Count > r2.column And r1.column < r2.column + r2.Columns.Count Then 17 | Collide = True 18 | Else 19 | Collide = False 20 | End If 21 | End Function 22 | Public Sub AddShips(board As Range) 23 | Set g_Ships = New Collection 24 | 25 | Dim s1 As New Ship 26 | 27 | s1.Size = 5 28 | Set s1.Position = GetShipPos(board, s1.Size) 29 | g_Ships.Add s1, "carrier" 30 | 31 | Dim s2 As New Ship 32 | s2.Size = 4 33 | Set s2.Position = GetShipPos(board, s2.Size) 34 | g_Ships.Add s2, "battleship" 35 | 36 | Dim s3 As New Ship 37 | s3.Size = 3 38 | Set s3.Position = GetShipPos(board, s3.Size) 39 | g_Ships.Add s3, "sub" 40 | 41 | Dim s4 As New Ship 42 | s4.Size = 3 43 | Set s4.Position = GetShipPos(board, s4.Size) 44 | g_Ships.Add s4, "cruiser" 45 | 46 | Dim s5 As New Ship 47 | s5.Size = 2 48 | Set s5.Position = GetShipPos(board, s5.Size) 49 | g_Ships.Add s5, "destroyer" 50 | End Sub 51 | Public Sub AddUserShips(board As Range) 52 | Set g_userShips = New Collection 53 | 54 | Dim s1 As New Ship 55 | 56 | s1.Size = 5 57 | Set s1.Position = Battleship.Range(userShip1) 58 | g_userShips.Add s1, "carrier" 59 | 60 | Dim s2 As New Ship 61 | s2.Size = 4 62 | Set s2.Position = Battleship.Range(userShip2) 63 | g_userShips.Add s2, "battleship" 64 | 65 | Dim s3 As New Ship 66 | s3.Size = 3 67 | Set s3.Position = Battleship.Range(userShip3) 68 | g_userShips.Add s3, "sub" 69 | 70 | Dim s4 As New Ship 71 | s4.Size = 3 72 | Set s4.Position = Battleship.Range(userShip4) 73 | g_userShips.Add s4, "cruiser" 74 | 75 | Dim s5 As New Ship 76 | s5.Size = 2 77 | Set s5.Position = Battleship.Range(userShip5) 78 | g_userShips.Add s5, "destroyer" 79 | End Sub 80 | Public Function GetShipPos(board As Range, ByVal Size As Integer) As Range 81 | Dim row As Integer, column As Integer 82 | Dim Horizontal As Integer 83 | 84 | Do 85 | Randomize 86 | row = (Rnd * (board.Rows.Count - 1)) + 1 87 | column = (Rnd * (board.Rows.Count - 1)) + 1 88 | Horizontal = Rnd 89 | 90 | If Horizontal = 1 Then 91 | If column - Size > 0 And column + Size < 10 Then 92 | If Rnd = 0 Then 93 | Set GetShipPos = board.Range(Cells(row, column), Cells(row, column + Size - 1)) 94 | Else 95 | Set GetShipPos = board.Range(Cells(row, column - Size + 1), Cells(row, column)) 96 | End If 97 | ElseIf column - Size > 0 Then 98 | Set GetShipPos = board.Range(Cells(row, column - Size + 1), Cells(row, column)) 99 | Else 100 | Set GetShipPos = board.Range(Cells(row, column), Cells(row, column + Size - 1)) 101 | End If 102 | Else 103 | If row - Size > 0 And row + Size < 10 Then 104 | If Rnd = 0 Then 105 | Set GetShipPos = board.Range(Cells(row, column), Cells(row + Size - 1, column)) 106 | Else 107 | Set GetShipPos = board.Range(Cells(row - Size + 1, column), Cells(row, column)) 108 | End If 109 | ElseIf row - Size > 0 Then 110 | Set GetShipPos = board.Range(Cells(row - Size + 1, column), Cells(row, column)) 111 | Else 112 | Set GetShipPos = board.Range(Cells(row, column), Cells(row + Size - 1, column)) 113 | End If 114 | End If 115 | Loop Until ValidSpot(GetShipPos) 116 | End Function 117 | 'Make sure the spot isn't occupied 118 | Private Function ValidSpot(r As Range) As Boolean 119 | Dim oShip As Ship 120 | For Each oShip In g_Ships 121 | If Code.Collide(r, oShip.Position) Then 122 | ValidSpot = False 123 | Exit Function 124 | End If 125 | Next 126 | ValidSpot = True 127 | End Function 128 | 129 | Public Sub SetHit(Target As Range) 130 | Target.Worksheet.Unprotect 131 | With Target.Borders(xlDiagonalDown) 132 | .LineStyle = xlContinuous 133 | .Color = ColorConstants.vbBlack 134 | .TintAndShade = 0 135 | .Weight = xlMedium 136 | End With 137 | With Target.Borders(xlDiagonalUp) 138 | .LineStyle = xlContinuous 139 | .Color = ColorConstants.vbBlack 140 | .TintAndShade = 0 141 | .Weight = xlMedium 142 | End With 143 | Target.Worksheet.Protect "" 144 | End Sub 145 | Public Function CheckWinner(ships As Collection) As Boolean 146 | Dim oShip As Ship 147 | For Each oShip In ships 148 | If oShip.Hits.Count < oShip.Position.Cells.Count Then 149 | CheckWinner = False 150 | Exit Function 151 | End If 152 | Next 153 | CheckWinner = True 154 | End Function 155 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/VBA-Code/ComputerPlayModule.txt: -------------------------------------------------------------------------------- 1 | Dim possibleCells As Collection 2 | Dim Hits As Range 3 | Public Sub Init() 4 | Dim b As Range 5 | Dim col As Integer, row As Integer 6 | 7 | Set possibleCells = New Collection 8 | Set b = Battleship.Range(board2) 9 | For col = 1 To b.Columns.Count 10 | For row = 1 To b.Rows.Count 11 | possibleCells.Add (b.Cells(row, col).Address) 12 | Next 13 | Next 14 | End Sub 15 | Public Sub Move() 16 | Dim index As Integer 17 | index = -1 18 | Dim oShip As Ship 19 | Dim isHit As Boolean 20 | For Each oShip In g_userShips 21 | If oShip.Hits.Count > 0 And oShip.Hits.Count < oShip.Position.Cells.Count Then 22 | index = GetHit(oShip) 23 | Exit For 24 | End If 25 | Next 26 | 27 | If index < 0 Then 28 | index = (Rnd * (possibleCells.Count - 1)) + 1 29 | End If 30 | Dim cell As Range 31 | Set cell = Battleship.Range(possibleCells(index)) 32 | isHit = False 33 | SetHit cell 34 | For Each oShip In g_userShips 35 | If oShip.isHit(cell, False) Then 36 | If CheckWinner(g_userShips) Then 37 | SetShipsVisible 38 | MsgBox "Computer wins!" 39 | Exit Sub 40 | End If 41 | isHit = True 42 | Exit For 43 | End If 44 | Next 45 | 46 | If IsHit = False Then 47 | Battleship.Unprotect 48 | Battleship.Cells(g_logRow, 2).value = "The Computer gets a miss on " & cell.Address 49 | Battleship.Names("ComputerMisses").RefersToRange.value = Battleship.Names("ComputerMisses").RefersToRange.value + 1 50 | g_logRow = g_logRow + 1 51 | Battleship.Protect "" 52 | End If 53 | possibleCells.Remove index 54 | End Sub 55 | 56 | Private Sub SetShipsVisible() 57 | Battleship.Unprotect 58 | Dim oShip As Ship 59 | For Each oShip In g_Ships 60 | Dim cell As Range 61 | For Each cell In oShip.Position.Cells 62 | If cell.Interior.Color <> ColorConstants.vbRed Then 63 | cell.Interior.Color = ColorConstants.vbBlack 64 | End If 65 | Next 66 | Next 67 | Battleship.Protect "" 68 | End Sub 69 | Private Function GetHit(oShip As Ship) As Integer 70 | Dim isHorizontal As Boolean 71 | If oShip.Hits.Count = 1 Then 72 | isHorizontal = Int((Rnd * 2)) = 1 73 | Else 74 | If oShip.Hits(1).row = oShip.Hits(2).row Then 75 | isHorizontal = True 76 | Else 77 | isHorizontal = False 78 | End If 79 | End If 80 | 81 | Dim index As Integer 82 | index = -1 83 | While index = -1 84 | If isHorizontal Then 85 | For Each Hit In oShip.Hits 86 | index = FindPossible(Hit.Offset(0, -1)) 87 | If index = -1 Then 88 | index = FindPossible(Hit.Offset(0, 1)) 89 | If index <> -1 Then 90 | Exit For 91 | End If 92 | Else 93 | Exit For 94 | End If 95 | Next 96 | If index = -1 Then 97 | isHorizontal = False 98 | End If 99 | Else 100 | For Each Hit In oShip.Hits 101 | index = FindPossible(Hit.Offset(-1, 0)) 102 | If index = -1 Then 103 | index = FindPossible(Hit.Offset(1, 0)) 104 | If index > -1 Then 105 | Exit For 106 | End If 107 | Else 108 | Exit For 109 | End If 110 | Next 111 | If index = -1 Then 112 | isHorizontal = True 113 | End If 114 | End If 115 | Wend 116 | GetHit = index 117 | End Function 118 | Private Function FindPossible(r As Range) 119 | Dim index As Integer 120 | Dim cell As Range 121 | For index = 1 To possibleCells.Count 122 | If possibleCells(index) = r.Address Then 123 | FindPossible = index 124 | Exit Function 125 | End If 126 | Next 127 | FindPossible = -1 128 | End Function 129 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/VBA-Code/ShipClass.txt: -------------------------------------------------------------------------------- 1 | Dim rPosition As Range 2 | Public HitCount As Integer 3 | Dim oSize As Integer 4 | Dim m_hits As Collection 5 | 6 | Public Property Get Position() As Range 7 | Set Position = rPosition 8 | End Property 9 | Public Property Set Position(ByVal value As Range) 10 | Set rPosition = value 11 | End Property 12 | 13 | Public Function IsHit(cell As Range, isPlayer As Boolean) As Boolean 14 | Attribute IsHit.VB_Description = "Checks if the current move is a hit" 15 | Attribute IsHit.VB_HelpID = 1 16 | 'Sample of attribute use on function level (show up in the objectbrowser(F2) --> Method --> Properties 17 | If Code.Collide(cell, Position) Then 18 | cell.Worksheet.Unprotect 19 | cell.Interior.Color = vbRed 20 | isHit = True 21 | Hits.Add cell 22 | If Hits.Count = Size Then 23 | Position.BorderAround Weight:=xlMedium 24 | End If 25 | 26 | If isPlayer Then 27 | Battleship.Cells(g_logRow, 2).value = "You get a hit on " & cell.Address & "!" 28 | Battleship.Names("PlayerHits").RefersToRange.value = Battleship.Names("PlayerHits").RefersToRange.value + 1 29 | Else 30 | Battleship.Cells(g_logRow, 2).value = "The Computer gets a hit on " & cell.Address 31 | Battleship.Names("ComputerHits").RefersToRange.value = Battleship.Names("ComputerHits").RefersToRange.value + 1 32 | End If 33 | g_logRow = g_logRow + 1 34 | cell.Worksheet.Protect "" 35 | isHit = True 36 | Else 37 | isHit = False 38 | End If 39 | End Function 40 | Public Property Get Hits() As Collection 41 | Set Hits = m_hits 42 | End Property 43 | Public Property Set Hits(ByVal value As Collection) 44 | Set m_hits = value 45 | End Property 46 | Private Sub Class_Initialize() 47 | HitCount = 0 48 | Set Hits = New Collection 49 | End Sub 50 | Public Property Get Size() As Integer 51 | Size = oSize 52 | End Property 53 | Public Property Let Size(ByVal vNewValue As Integer) 54 | oSize = vNewValue 55 | End Property 56 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/VBA-Code/ThisWorkbook.txt: -------------------------------------------------------------------------------- 1 | Private Sub Workbook_Open() 2 | Code.AddShips Battleship.Range(board1) 3 | Code.AddUserShips Battleship.Range(board2) 4 | ComputerPlay.Init 5 | g_gameEnded=false 6 | g_logRow = Battleship.Names("LogStart").RefersToRange.row+1 7 | End Sub 8 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/csv/Sample9-1.txt: -------------------------------------------------------------------------------- 1 | This file is used in sample 9 2 | Sales per region 3 | "Period","Europe","Africa","Asia","North America","South America","Austraila" 4 | 2010-01,12.3,8,55.1,35,14.1,12.1 5 | 2010-02,13.9,9.1,51.1,35.3,14.4,11.1 6 | 2010-03,11.4,8.7,54.7,32.1,13.1,12.3 7 | 2010-04,12.1,9.2,53.3,35,11.2,10.4 8 | 2010-05,9.4,10,45.3,25.8,12.4,13.1 9 | 2010-06,14.3,9.8,49.4,29.2,14.1,14.2 10 | 2010-07,7.3,11,50.0,31.2,14.9,12.3 11 | 2010-08,19.3,10.1,49.6,35,13.3,10.1 12 | 2010-09,21.0,8.5,41.1,35,14.5,9.3 13 | 2010-10,23.8,9.1,45,32,16.1,11.1 14 | 2010-11,25.6,10.8,49,33.6,14.4,13.4 15 | 2010-12,17.2,12.1,43.2,35.1,15.1,15.1 16 | EOF -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/SampleApp/csv/Sample9-2.txt: -------------------------------------------------------------------------------- 1 | This file is used in sample 9 2 | ID Product Items In Stock Purchase Price Price 3 | 12001 Nails 37 1,3 3,99 4 | 12002 Hammer 5 5,33 12,10 5 | 12003 Saw 12 8,99 15,37 6 | 12010 Drill 20 4,3 8,00 7 | 12011 Crowbar 7 13,77 23,48 -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1 Sample/readme.txt: -------------------------------------------------------------------------------- 1 | EPPlus 4.0.1 2 | 3 | Visit epplus.codeplex.com for the latest information 4 | 5 | EPPlus-Create Advanced Excel spreadsheet. 6 | 7 | New features 8 | 9 | Replaced Packaging API with DotNetZip 10 | * This will remove any problems with Isolated Storage and enable multi threading 11 | 12 | 13 | New Cell store 14 | * Less memory consumtion 15 | * Insert columns (not on the range level) 16 | * Faster row inserts, 17 | 18 | Formula Parser 19 | * Calculates all formulas in a workbook, a worksheet or in a specified range 20 | * 100+ functions implemented 21 | * Access via Calculate methods on Workbook, Worksheet and Range objects. 22 | * Add custom/missing Excel functions via Workbook.FormulaParserManager. 23 | * Samples added to the EPPlusSamples project. 24 | 25 | The formula parser does not support Array Formulas 26 | * Intersect operator (Space) 27 | * References to external workbooks 28 | * And probably a whole lot of other stuff as well :) 29 | 30 | Perfomance 31 | *Of course the performance of the formula parser is nowhere near Excels.Our focus has been functionality. 32 | 33 | Agile Encryption (Office 2012-) 34 | * Support for newer type of encryption. 35 | 36 | Minor new features 37 | * Chart worksheets 38 | * New Chart Types Bubblecharts 39 | * Radar Charts 40 | * Area Charts 41 | * And lots of bugfixes... 42 | 43 | Beta 2 Changes 44 | * Fixed bug when using RepeatColumns & RepeatRows at the same time. 45 | * VBA project will be left untouched if its not accessed. 46 | * Fixed problem with strings on save. 47 | * Added locks to the cellstore for access by mulitple threads. 48 | * Implemented Indirect function 49 | * Used DisplayNameAttribute to generate column headers from LoadFromCollection 50 | * Rewrote ExcelRangeBase.Copy function. 51 | * Added caching to Save ZipStream for Cells and shared strings to speed up the Save method. 52 | * Added Missing InsertColumn and DeleteColumn 53 | * Added pull request to support Date1904 54 | * Added pull request ExcelWorksheet.LoadFromDataReader 55 | 56 | Release Candidare changes 57 | * Fixed some problems with Range.Copy Function 58 | * InsertColumn and Delete column didn't work in some cases 59 | * Chart.DisplayBlankAs had the wrong default type in Excel 2010+ 60 | * Datavalidation list overflow cauesed corruption of the package 61 | * Fixed a few Calculation when refering ranges (for example If) function and some 62 | * Added ChartAxis.DisplayUnit 63 | * Fixed a bug related to shared formulas 64 | * Named styles faild in some cases. 65 | * Style.Indent got an invalid value in some cases. 66 | * Fixed a problem with AutofitColumns method. 67 | * Performance fix. 68 | * An a whole lot of other small fixes. 69 | 70 | 4.0.1 Fixes 71 | * VBA unreadable content 72 | * Fixed a few issues with InsertRow and DeleteRow 73 | * Fixed bug in Average and AverageA 74 | * Handling of Div/0 in functions 75 | * Fixed VBA CodeModule error when copying a worksheet. 76 | * Value decoding when reading str element for cell value. 77 | * Better exception when accessing a worksheet out of range in the Excelworksheets indexer. 78 | * Added Small and Large function to formula parser. Performance fix when encountering an unknown function. 79 | * Fixed handling strings in formulas 80 | * Calculate hanges if formula start with a parenthes. 81 | * Worksheet.Dimension returned an invalid range in some cases. 82 | * Rowheight was wrong in some cases. 83 | * ExcelSeries.Header had an incorrect validation check. -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus 4.0.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus 4.0.1.zip -------------------------------------------------------------------------------- /DataConvert/EEPlus/EPPlus.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/EEPlus/EPPlus.dll -------------------------------------------------------------------------------- /DataConvert/EEPlus/readme.txt: -------------------------------------------------------------------------------- 1 | EPPlus 4.0.1 2 | 3 | Visit epplus.codeplex.com for the latest information 4 | 5 | EPPlus-Create Advanced Excel spreadsheet. 6 | 7 | New features 8 | 9 | Replaced Packaging API with DotNetZip 10 | * This will remove any problems with Isolated Storage and enable multi threading 11 | 12 | 13 | New Cell store 14 | * Less memory consumtion 15 | * Insert columns (not on the range level) 16 | * Faster row inserts, 17 | 18 | Formula Parser 19 | * Calculates all formulas in a workbook, a worksheet or in a specified range 20 | * 100+ functions implemented 21 | * Access via Calculate methods on Workbook, Worksheet and Range objects. 22 | * Add custom/missing Excel functions via Workbook.FormulaParserManager. 23 | * Samples added to the EPPlusSamples project. 24 | 25 | The formula parser does not support Array Formulas 26 | * Intersect operator (Space) 27 | * References to external workbooks 28 | * And probably a whole lot of other stuff as well :) 29 | 30 | Perfomance 31 | *Of course the performance of the formula parser is nowhere near Excels.Our focus has been functionality. 32 | 33 | Agile Encryption (Office 2012-) 34 | * Support for newer type of encryption. 35 | 36 | Minor new features 37 | * Chart worksheets 38 | * New Chart Types Bubblecharts 39 | * Radar Charts 40 | * Area Charts 41 | * And lots of bugfixes... 42 | 43 | Beta 2 Changes 44 | * Fixed bug when using RepeatColumns & RepeatRows at the same time. 45 | * VBA project will be left untouched if its not accessed. 46 | * Fixed problem with strings on save. 47 | * Added locks to the cellstore for access by mulitple threads. 48 | * Implemented Indirect function 49 | * Used DisplayNameAttribute to generate column headers from LoadFromCollection 50 | * Rewrote ExcelRangeBase.Copy function. 51 | * Added caching to Save ZipStream for Cells and shared strings to speed up the Save method. 52 | * Added Missing InsertColumn and DeleteColumn 53 | * Added pull request to support Date1904 54 | * Added pull request ExcelWorksheet.LoadFromDataReader 55 | 56 | Release Candidare changes 57 | * Fixed some problems with Range.Copy Function 58 | * InsertColumn and Delete column didn't work in some cases 59 | * Chart.DisplayBlankAs had the wrong default type in Excel 2010+ 60 | * Datavalidation list overflow cauesed corruption of the package 61 | * Fixed a few Calculation when refering ranges (for example If) function and some 62 | * Added ChartAxis.DisplayUnit 63 | * Fixed a bug related to shared formulas 64 | * Named styles faild in some cases. 65 | * Style.Indent got an invalid value in some cases. 66 | * Fixed a problem with AutofitColumns method. 67 | * Performance fix. 68 | * An a whole lot of other small fixes. 69 | 70 | 4.0.1 Fixes 71 | * VBA unreadable content 72 | * Fixed a few issues with InsertRow and DeleteRow 73 | * Fixed bug in Average and AverageA 74 | * Handling of Div/0 in functions 75 | * Fixed VBA CodeModule error when copying a worksheet. 76 | * Value decoding when reading str element for cell value. 77 | * Better exception when accessing a worksheet out of range in the Excelworksheets indexer. 78 | * Added Small and Large function to formula parser. Performance fix when encountering an unknown function. 79 | * Fixed handling strings in formulas 80 | * Calculate hanges if formula start with a parenthes. 81 | * Worksheet.Dimension returned an invalid range in some cases. 82 | * Rowheight was wrong in some cases. 83 | * ExcelSeries.Header had an incorrect validation check. -------------------------------------------------------------------------------- /DataConvert/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace DataConvert 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// 应用程序的主入口点。 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new FormMain()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /DataConvert/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过下列属性集 6 | // 控制。更改这些属性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("DataConvert")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("China")] 12 | [assembly: AssemblyProduct("DataConvert")] 13 | [assembly: AssemblyCopyright("Copyright © China 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 属性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("d17bbddd-c67f-49e2-a168-bbbc3426970e")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DataConvert/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.18444 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DataConvert.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DataConvert.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /DataConvert/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /DataConvert/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.18444 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DataConvert.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DataConvert/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DataConvert/README.md: -------------------------------------------------------------------------------- 1 | #excel2Json 2 | excel 转换 Json 工具 3 | [exe 下载地址: ] 4 | ##工具介绍 5 | 采用c#编写开发, 将excel表格的数据转换成json格式,方便程序使用. 6 | 7 | ## 工具特点 8 | 1.该工具支持一个excel多个工作薄,方便相同模块的表格存放到一个excel 9 | 2.工具可以停靠在窗口顶部隐藏,类似qq的功能 10 | 3.工具可以导出txt格式,方便导入到数据库 11 | 4.支持bat脚本,可以简单扩展你的想要的功能 12 | 13 | ## 使用说明 14 | ### 注意事项: 15 | 1.程序在启动的时候,会读取exe所在目录下的文件夹,这一步很重要 16 | 2.exe同级文件夹下必须存在 json/txt/xlsx 这三个目录,如果没有程序会自动生成 17 | 3.excel文件必须存放在xlsx目录下,其他目录不予读取 18 | 4.如果xlsx文件夹出现多层目录结构,该工具会自动检索出该目录下所有的excel文件 19 | 5.如果使用过程中出现问题,请多留意下边的log提示信息 20 | ###表格配置 21 | >多工作薄配置表格(必须存在) 22 | 23 | |sheet| name |index |desc| 24 | |-------| --------| ------- | ------ | 25 | |lv |lv |1|关卡表| 26 | 27 | 说明: 28 | sheet: 具体的数据表格名字,excel必须有工作薄 29 | name: 导出json时的文件名 30 | index:该工作薄在excel的位置 31 | desc:对该工作薄的一个简单描述说明,程序不会使用,可作为注释 32 | 33 | > 具体的数据表格: 34 | 35 | |id|name|PowerCost|LvLimite| 36 | |-------| --------| ------- | ------ | 37 | |关卡编号|关卡名称|消耗体力|开启等级| 38 | |10010001|英雄出世1| 5| 1| 39 | |10010002|英雄出世2| 6| 2| 40 | |10010003|英雄出世3| 7| 3| 41 | |10010004|英雄出世4| 8| 4| 42 | 第一行为最终json对象的key 43 | 第二行为中文注释说明 44 | 第三行之后为具体的数据 45 | ####最终的excel请参考 excel2Json/DataConvert/bin/Debug/策划/xlsx/数值/test.xlsx, 最终转换的json 46 | ```json 47 | [ 48 | { 49 | "id": "10010001", 50 | "name": "英雄出世1", 51 | "PowerCost": "5", 52 | "LvLimite": "1" 53 | }, 54 | { 55 | "id": "10010002", 56 | "name": "英雄出世2", 57 | "PowerCost": "6", 58 | "LvLimite": "2" 59 | }, 60 | { 61 | "id": "10010003", 62 | "name": "英雄出世3", 63 | "PowerCost": "7", 64 | "LvLimite": "3" 65 | }, 66 | { 67 | "id": "10010004", 68 | "name": "英雄出世4", 69 | "PowerCost": "8", 70 | "LvLimite": "4" 71 | } 72 | ] 73 | ``` 74 | 75 | 76 | ### 工具使用 77 | 1.bat脚本:可指定bat脚本文件路径,按下F12即可执行该bat脚本,示例脚本: 78 | 79 | :: 拷贝文件到目标文件 80 | :: copy /y 81 | @echo off 82 | cd /d %~dp0 83 | set desDir="D:\project\mhgjClient\assets\resources\json" 84 | :: 遍历所在文件夹的json文件 85 | for /R %%s in (*.json) do ( 86 | echo %%s 87 | copy /y %%s %desDir% 88 | ) 89 | pause 90 | 91 | 2.载入excel之后,右击listView的item,弹出菜单,可以打开相应的 文件/文件夹, 如果文件夹已经打开,则该文件夹窗口置顶. 92 | 3.选中listView的item之后,按下 空格键 可以迅速打开excel文件 93 | ## 关于 94 | 该工具是自己游戏开发生涯中的一个小积累 95 | 如果你喜欢,请告诉你的小伙伴, 96 | 如果不喜欢,请告诉我哪里不好(企鹅 774177933),或者直接在Issues里面提问,帮助我完善它 97 | 98 | QQ打赏: 99 | ![enter image description here](http://7xq9nm.com1.z0.glb.clouddn.com/qqPay.png) 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /DataConvert/Res/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/Res/icon.ico -------------------------------------------------------------------------------- /DataConvert/Res/notifity.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/Res/notifity.ico -------------------------------------------------------------------------------- /DataConvert/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /DataConvert/bin/Debug/策划/xlsx/数值/test.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/bin/Debug/策划/xlsx/数值/test.xlsx -------------------------------------------------------------------------------- /DataConvert/libiconv-2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tidys/excel2Json/a6b77c755533cc7b1691ee219ec725db35bb4c4f/DataConvert/libiconv-2.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # excel2Json 2 | excel 转换 Json 工具   3 | - [v1.1 点击下载](https://github-production-repository-file-5c1aeb.s3.amazonaws.com/67108297/1976222?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20180505%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180505T014717Z&X-Amz-Expires=300&X-Amz-Signature=df7182374cf1967eb5c6c88bf8a7d3be023d1237a6a62194fcc8f1c124c5d85e&X-Amz-SignedHeaders=host&actor_id=7894208&response-content-disposition=attachment%3Bfilename%3Dtools.zip&response-content-type=application%2Fzip) 4 | 5 | ## 工具介绍 6 | 采用c#编写开发, 将excel表格的数据转换成json格式,方便程序使用. 7 | 8 | ## 工具特点 9 | 1.该工具支持一个excel多个工作薄,方便相同模块的表格存放到一个excel 10 | 2.工具可以停靠在窗口顶部隐藏,类似qq的功能 11 | 3.工具可以导出txt格式,方便导入到数据库 12 | 4.支持bat脚本,可以简单扩展你的想要的功能 13 | 14 | ## 使用说明 15 | ### 注意事项: 16 | 1.程序在启动的时候,会读取exe所在目录下的文件夹,这一步很重要 17 | 2.exe同级文件夹下必须存在 json/txt/xlsx 这三个目录,如果没有程序会自动生成 18 | 3.excel文件必须存放在xlsx目录下,其他目录不予读取 19 | 4.如果xlsx文件夹出现多层目录结构,该工具会自动检索出该目录下所有的excel文件 20 | 5.如果使用过程中出现问题,请多留意下边的log提示信息 21 | ###表格配置 22 | >多工作薄配置表格(必须存在) 23 | 24 | |sheet| name |index |desc| 25 | |-------| --------| ------- | ------ | 26 | |lv |lv |1|关卡表| 27 | 28 | 说明: 29 | sheet: 具体的数据表格名字,excel必须有工作薄 30 | name: 导出json时的文件名 31 | index:该工作薄在excel的位置 32 | desc:对该工作薄的一个简单描述说明,程序不会使用,可作为注释 33 | 34 | > 具体的数据表格: 35 | 36 | |id|name|PowerCost|LvLimite| 37 | |-------| --------| ------- | ------ | 38 | |关卡编号|关卡名称|消耗体力|开启等级| 39 | |10010001|英雄出世1| 5| 1| 40 | |10010002|英雄出世2| 6| 2| 41 | |10010003|英雄出世3| 7| 3| 42 | |10010004|英雄出世4| 8| 4| 43 | 第一行为最终json对象的key 44 | 第二行为中文注释说明 45 | 第三行之后为具体的数据 46 | ####最终的excel请参考 excel2Json/DataConvert/bin/Debug/策划/xlsx/数值/test.xlsx, 最终转换的json 47 | ```json 48 | [ 49 | { 50 | "id": "10010001", 51 | "name": "英雄出世1", 52 | "PowerCost": "5", 53 | "LvLimite": "1" 54 | }, 55 | { 56 | "id": "10010002", 57 | "name": "英雄出世2", 58 | "PowerCost": "6", 59 | "LvLimite": "2" 60 | }, 61 | { 62 | "id": "10010003", 63 | "name": "英雄出世3", 64 | "PowerCost": "7", 65 | "LvLimite": "3" 66 | }, 67 | { 68 | "id": "10010004", 69 | "name": "英雄出世4", 70 | "PowerCost": "8", 71 | "LvLimite": "4" 72 | } 73 | ] 74 | ``` 75 | 76 | 77 | ### 工具使用 78 | 1.bat脚本:可指定bat脚本文件路径,按下F12即可执行该bat脚本,示例脚本: 79 | 80 | :: 拷贝文件到目标文件 81 | :: copy /y 82 | @echo off 83 | cd /d %~dp0 84 | set desDir="D:\project\mhgjClient\assets\resources\json" 85 | :: 遍历所在文件夹的json文件 86 | for /R %%s in (*.json) do ( 87 | echo %%s 88 | copy /y %%s %desDir% 89 | ) 90 | pause 91 | 92 | 2.载入excel之后,右击listView的item,弹出菜单,可以打开相应的 文件/文件夹, 如果文件夹已经打开,则该文件夹窗口置顶. 93 | 3.选中listView的item之后,按下 空格键 可以迅速打开excel文件 94 | ## 关于 95 | 该工具是自己游戏开发生涯中的一个小积累 96 | 如果你喜欢,请告诉你的小伙伴, 97 | 如果不喜欢,请告诉我哪里不好(企鹅 774177933),或者直接在Issues里面提问,帮助我完善它 98 | ### QQ群 99 | CocosCreator插件开发交流: 224756137 100 | 101 | ![群图片](http://7xq9nm.com1.z0.glb.clouddn.com/%E6%8F%92%E4%BB%B6%E4%BA%A4%E6%B5%81%E7%BE%A4.png) 102 | 103 | 点击链接加入群【CocosCreator插件开发交流】:https://jq.qq.com/?_wv=1027&k=5ANhoTC 104 | 105 | ### QQ打赏: 106 | ![enter image description here](http://7xq9nm.com1.z0.glb.clouddn.com/qqPay.png) 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | --------------------------------------------------------------------------------