??
A two-month-old published blog, "Introducing an open source class Excel spreadsheet Software" has sparked a buzz: There are nearly 2000 view, more than 20 reviews in the blog park. At the same time, there are enthusiastic readers how to store Excel cloud files in spreaddesing by reading and loading Excel files in cloud mode. In this article, we are concerned about the cloud storage for the actual practice---based on spreaddesign source code base.
System Prerequisites:
- This article chooses the domestic comparatively popular seven qiniu storage.
- SpreadDesign.exe has been upgraded to the latest spread Studio 8.35.20143.0 kernel
- . NETFramework 4.0
- Windows 8.1 64 System
- Visual Studio 2013 Community Edition
The list of features to be implemented is as follows:
Register seven Qiniu Storage account (please skip this section if you have an account)
Seven Qiniu Storage-home http://www.qiniu.com/(friendship to seven cattle to make a propaganda, thank you seven cattle to the Grape City control provides seven Qiniu storage coupons)
Seven Qiniu storage core team members from Shanda, Jinshan, network Dragon, Hewlett-Packard and other well-known internet companies. The core members have been cooperating for many years. Company founder Mr. Xu Xiwei in Jinshan, Baidu and Shanda and other companies as important leadership positions, with many years of practical experience in the storage industry, known as the most suitable for cloud storage of a few people.
Say 7 Cow cloud storage big story! Different from other cloud storage at home and abroad, seven KN self-developed fully distributed architecture solves the risk of other cloud storage single data center architecture, while the first two-way acceleration feature accelerates data upload and download, so that data access speed is higher than average of traditional scheme 50% . In addition, the unique features of the seven Qiniu storage, such as mirrored storage , client through balls , breakpoint upload , cloud rich media processing , and so on, also greatly increase the efficiency of development, minimizing the waste of server resources.
Seven Cattle official Novice road link experience Users:
- Storage space 1GB
- Put request 10,000 times per month
- Monthly Download Traffic 1GB
- Get request 100,000 times per month
- Create 1 spaces
- Support for rich media uploads only
To upgrade to a standard user:
- Storage space 10GB
- Put request 100,000 times per month
- Monthly Download Traffic 10GB
- Get request 1 million times per month
- Create 20 spaces
- All features of seven kn are used
7 Qiniu Storage requires 3 information to be used.
1,ak (AccessKey)
2,sk (Secretkey)
3, Bucket
Enter account Settings-key to find the following information:
For a public key and secret key security issue, see where is the official public key? 》
Configure a space (Bucket), as in this article I'm using "grapecity" Space--- space note the case is consistent with the code :
Configuring the Seven Qiniu C # development environment
In the seven Cattle Developer Center, we can see that seven KN offers a number of SDKs:
Click the page to jump to the C # SDK usage guide.
Download the seven KN C # SDK and the third party open source project json.net via the URL provided by the seven cattle website.
Also in the GCDN community, download images are available: http://gcdn.gcpowertools.com.cn/showtopic.aspx?topicid=13778&postid=73156#73156
Configuration is easy, add these 2 DLL references:
Qiniu.DLL
Newtonsoft.Json.dll
Code implementation
Initializing the seven KN SDK code
Qiniu.Conf.Config.ACCESS_KEY ="5iujaj62q9eqc94uf0sgfzxwvtp-9c_hkq_2jc-j"; Qiniu.Conf.Config.SECRET_KEY="rmrv45m6j-gplvz2pagndn3i-mmtxndcjmqwswkg";Private Const stringBucket ="grapecity";Private Const stringDomain = Bucket +". qiniudn.com";
Note: Access_key, Secret_key Please use the seven-cow admin interface to apply, each can apply for 2 pairs.
List File Listing code
Public voidList (ListView ListView1,stringBucket =buckets) {Qiniu.RSF.RSFClient RSF=NewQiniu.RSF.RSFClient (bucket); Rsf. Prefix=""; Rsf. Limit= -; List<DumpItem>items; while(items = RSF. Next ())! =NULL) { foreach(Dumpitem Iteminchitems) {Stat (ListView1, item. Key, bucket); } } } Public voidStat (ListView ListView1,stringKeystringBucket =buckets) {rsclient Client=Newrsclient (); Entry Entry= client. Stat (NewEntrypath (bucket, key)); if(entry. OK) {ListViewItem Item=NewListViewItem (New string[]{key, entry. MimeType, Datetime.fromfiletime (entry. Puttime). Tolongdatestring (), entry. Fsize.tostring ()}); LISTVIEW1.ITEMS.ADD (item); } Else{Console.WriteLine ("Failed to Stat"); } }
Note: Key can use file name, Chinese filename is also available.
Delete File code:
Public BOOLDelete (stringKeystringBucket =buckets) {rsclient Client=Newrsclient (); Callret ret= client. Delete (NewEntrypath (bucket, key)); returnret. OK; }
Download the file code
Public stringDownLoad (stringKey1,stringDomain =Domain) { stringBASEURL =getpolicy.makebaseurl (domain, key1); stringPrivate_url =getpolicy.makerequest (BASEURL); Private_url=Httputility.urlpathencode (Private_url); Try{HttpWebRequest Request=(HttpWebRequest) webrequest.create (Private_url); HttpWebResponse Response=(HttpWebResponse) request. GetResponse (); Stream Stream=Response. GetResponseStream (); stringNewFile = AppDomain.CurrentDomain.BaseDirectory +Key1; FileStream Write=NewFileStream (NewFile, FileMode.OpenOrCreate); Stream. CopyTo (write); Stream. Close (); Write. Close (); returnNewFile; } Catch(Exception ex) {System.Diagnostics.Debug.Assert (false, ex. Message); return ""; } }
Designing the Excel Management UI
The "Remote management view" pop-up provides 3 cloud storage-related features:
- List: Get the cloud, corresponding to Access_key, Secret_key, bucket files
- Delete:: Deleting files from the cloud
- DownLoad: Download selected files from the cloud,
Download the cloud files, directly to the Spread.openexcel, can be edited on the spreaddesign, printing, very convenient.
When you're done editing, click "Save to the cloud" and save it in the pop-up dialog box as "locally modified stored files. xlsx", then the program is automatically saved to the cloud.
In the Cloud Content management interface, the refresh can see that the file is automatically uploaded:
Full Source:
Http://git.oschina.net/GrapeCity/SpreadDesigner
Gossip: There are still a few seven qiniu storage of the trial coupon (a seven cow account can only be used once), there is a need to please message communication.
"Introduction of an Open source class Excel spreadsheet Software" continued: Seven Cow cloud storage combat (C #)