$(function () {
$("#Spreadsheet").ejSpreadsheet({
allowWrap: true,
sheets: [
{
rangeSettings: [{ dataSource: sheet2DataSrc }],
}],
loadComplete: "onLoadComplete"
});
});
function onLoadComplete(args) {
console.log("sample", args);
var xlObj = this;
if (!this.isImport) {
this.setWidthToColumns([200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]);
this.addNewSheet();
this.XLEdit.updateValue("A1", "Scholarship Name");
this.XLEdit.updateValue("B1", "Page Url");
this.XLFormat.format({ "style": { "vertical-align": "middle", "text-align": "center", "font-weight": "bold" } }, "A1:C1");
this.setWidthToColumns([200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]);
this.performSelection("A4");
this.XLCellType.addCellTypes("C1", { 'type': ej.Spreadsheet.CustomCellType.DropDownList, 'dataSourceRange': 'A2:A23', 'dataSourceSheetIndex': 1 }, 2);
//this.XLCellType.addCellTypes("D1", { 'type': ej.Spreadsheet.CustomCellType.DropDownList, 'dataSourceRange': 'A2:A23', 'dataSourceSheetIndex': 1 }, 2);
//this.XLCellType.addCellTypes("E1", { 'type': ej.Spreadsheet.CustomCellType.DropDownList, 'dataSourceRange': 'A2:A23', 'dataSourceSheetIndex': 1 }, 2);
//this.XLCellType.addCellTypes("F1", { 'type': ej.Spreadsheet.CustomCellType.DropDownList, 'dataSourceRange': 'A2:A23', 'dataSourceSheetIndex': 1 }, 2);
}
$('#saveSheet').on('click', function () {
var xlObj = $("#Spreadsheet").data("ejSpreadsheet"), exportProp = xlObj.XLExport.getExportProps(), filename = "Milga";
$.ajax({
type: "POST",
data: { fileName: filename, sheetModel: exportProp.model, sheetData: exportProp.data },
url: "/Milga/SaveFiletoDB",
success: function (data) {
// Success code here.
}
});
});
}
and server side is:
if (fileName.Length > 0)
{
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
Stream dataStream = Spreadsheet.Save(sheetModel, sheetData, ExportFormat.XLSX, ExcelVersion.Excel2013);
dataStream.Position = 0;
//Byte[] dataBytes = new BinaryReader(dataStream).ReadBytes(Convert.ToInt32(dataStream.Length));
IWorkbook workbook = excelEngine.Excel.Workbooks.Open(dataStream);
var rows = workbook.ActiveSheet.Rows;
}
problem is in row cells i am getting all the data but only dropdown value on C1 i got null