Hi,
Thanks for your posting and using Aspose.Cells for Cloud.
Well, you may use importdata resource for your needs.
e.g
http://api.aspose.com/v1.1/cells/testimport.xlsx/importdata
You may fill up
arrays/ lists etc. and then import data to the sheet accordingly. We have
written an example which we will provide it here for your reference, you
may refer to it and create your own code accordingly.
We have also attached the code text file for you to use it.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using [System.Net](http://system.net/);
using [System.IO](http://system.io/);
using Aspose.Cells.Cloud.SDK;
using Aspose.Cells.Cloud.SDK.Cells;
using Aspose.Cells.Cloud.SDK.Common;
using System.Xml.Serialization;
using System.Xml;
namespace TestConsole
{
public class CustomCase
{
const String BaseProductUri = @“http:[//api.aspose.com/v1.1](https://api.aspose.com/v1.1)”;
const String AppSID = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
const String AppKey = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;
public string Sign(string url)
{
try
{
UriBuilder builder = new UriBuilder(url);
if (builder.Query != null && builder.Query.Length > 1)
{
builder.Query = String.Format("{0}&appSID={1}", builder.Query.Substring(1), AppSID);
}
else
{
builder.Query = String.Format(“appSID={0}”, AppSID);
}
builder.Path = builder.Path.TrimEnd(’/’);
byte[] privateKey = System.Text.Encoding.UTF8.GetBytes(AppKey);
System.Security.Cryptography.HMACSHA1 algorithm = new System.Security.Cryptography.HMACSHA1(privateKey);
byte[] sequence = System.Text.ASCIIEncoding.ASCII.GetBytes(builder.Uri.AbsoluteUri);
byte[] hash = algorithm.ComputeHash(sequence);
String signature = Convert.ToBase64String(hash);
signature = signature.TrimEnd(’=’);
signature = System.Web.HttpUtility.UrlEncode(signature);
signature = System.Text.RegularExpressions.Regex.Replace(signature, “%[0-9a-f]{2}”, e => e.Value.ToUpper());
return String.Format("{0}&signature={1}", builder.Uri.AbsoluteUri, signature);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public void Test()
{
try
{
String baseurl = @“http:[//api.aspose.com/v1.1/cells/testimport.xlsx/importdata](https://api.aspose.com/v1.1/cells/testimport.xlsx/importdata)”;
String url;
String xml = “”;
int[] nos = new int[] { 1, 2, 3, 4, 5 };
string[] tasklist = new string[] { “task 1”, “task 2”, “task 3”, “task 4”, “task 5” };
int[] times = new int[] { 11, 20, 9, 14, 2 };
string[] States = new string[] { “Release”, “Release”, “Release”, “Release”, “Open” };
string[] CreateTimes = new string[] { “2014-03-13”, “2014-03-13”, “2014-03-13”, “2014-03-13”, “2014-03-13” };
xml = ImportIntArrayOption(“Sheet1”, 2, 1, false, true, nos);
url = Sign(baseurl);
using (HttpWebResponse response = POST(url, xml)) { }
xml = ImportStringArrayOption(“Sheet1”, 2, 2, false, true, tasklist);
url = Sign(baseurl);
using (HttpWebResponse response = POST(url, xml)) { }
xml = ImportIntArrayOption(“Sheet1”, 2, 3, false, true, times);
url = Sign(baseurl);
using (HttpWebResponse response = POST(url, xml)) { }
xml = ImportStringArrayOption(“Sheet1”, 2, 4, false, true, States);
url = Sign(baseurl);
using (HttpWebResponse response = POST(url, xml)) { }
xml = ImportStringArrayOption(“Sheet1”, 2, 5, false, true, CreateTimes);
url = Sign(baseurl);
using (HttpWebResponse response = POST(url, xml)){}
url = @“http:[//api.aspose.com/v1.0/storage/file/testimport.xlsx](https://api.aspose.com/v1.0/storage/file/testimport.xlsx)”;
Download(@“D:\Projects\Test\Aspose.Cells.Cloud\testimport.xlsx”, url);
}
catch (Exception e)
{
Console.Write(e.Message);
}
}
public HttpWebResponse POST(String url, String xml)
{
try
{
Uri uri = new Uri(url);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Method = “POST”;
request.ContentType = “application/xml”;
if (String.IsNullOrEmpty(xml))
{
request.ContentLength = 0;
}
else
{
byte[] arr = System.Text.Encoding.UTF8.GetBytes(xml);
request.ContentLength = arr.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(arr, 0, arr.Length);
dataStream.Close();
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
return response;
}
catch (Exception ex)
{
throw ex;
}
}
public HttpWebResponse GET(String url)
{
try
{
Uri uri = new Uri(url);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Method = “GET”;
request.ContentType = “application/xml”;
request.ContentLength = 0;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
return response;
}
catch (Exception ex)
{
throw ex;
}
}
private string ImportIntArrayOption(String sheetname, int row, int column, bool IsInsert, bool IsVertical, int[] data)
{
StringBuilder sb = new StringBuilder();
sb.Append("");
sb.AppendFormat("{0}{1}{2}", sheetname, row, column);
sb.AppendFormat("{0}{1}", IsInsert.ToString().ToLower(), IsVertical.ToString().ToLower());
sb.Append("");
for (int i = 0; i < data.Length; i++)
{
sb.AppendFormat("<int>{0}</int>", data[i]);
}
sb.Append("");
sb.Append("");
return sb.ToString();
}
private string ImportStringArrayOption(String sheetname, int row, int column, bool IsInsert, bool IsVertical, string[] data)
{
StringBuilder sb = new StringBuilder();
sb.Append("");
sb.AppendFormat("{0}{1}{2}", sheetname, row, column);
sb.AppendFormat("{0}{1}", IsInsert.ToString().ToLower(), IsVertical.ToString().ToLower());
sb.Append("");
for (int i = 0; i < data.Length; i++)
{
sb.AppendFormat("<string>{0}</string>", data[i]);
}
sb.Append("");
sb.Append("");
return sb.ToString();
}
private string GetImportArrayOptionTag(TypeCode type, bool isBegin)
{
switch (type)
{
case TypeCode.Int16:
case TypeCode.Int32:
case TypeCode.Int64:
return isBegin ? “” : “”;
default:
return isBegin ? “” : “”;
}
}
private string ImportImportBatchDataOption(String sheetname, bool IsInsert)
{
int row = 0, column = 0;
StringBuilder sb = new StringBuilder();
sb.Append("");
sb.AppendFormat("{0}", sheetname);
sb.Append("");
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 10; j++)
{
sb.AppendFormat("");
sb.AppendFormat("{0}", row + i);
sb.AppendFormat("{0}", column + j);
sb.AppendFormat("{0}", i % 3 == 0 ? “int” : “string”);
sb.AppendFormat("<value>{0}</value>", i + j);
sb.AppendFormat("");
}
}
sb.Append("");
sb.Append("");
return sb.ToString();
}
public void Download(String path,String url)
{
using (HttpWebResponse response = GET(Sign(url)))
{
using (var stream = File.Create(path))
{
response.GetResponseStream().CopyTo(stream);
}
}
}
}
}```