AUTHOR: Peter Milchev
DATE POSTED: November 12, 2018
When you load a file in the Spreadsheet, sometimes it has a broken appearance, it overflows and the scroll is not working.
Most commonly the reasons for the unexpected behavior are JavaScript errors or loading some Excel files. Most of the Excel files that cause such an issue are loaded server-side and contain frozen rows and columns.
Remove the frozen rows and columns when loading the file:
protected
void
Page_Init(
object
sender, EventArgs e)
{
var provider =
new
SpreadsheetDocumentProvider(Server.MapPath(
"~/App_Data/MyExcelFile.xlsx"
));
RadSpreadsheet1.Provider = provider;
foreach
(var sheet
in
provider.GetSheets())
sheet.FrozenColumns = 0;
sheet.FrozenRows = 0;
}
If you need the frozen rows and columns to persist, you can load the file on the client by saving it to a base64string.
Code-behind:
Page_Load(
//https://stackoverflow.com/questions/25919387/c-sharp-converting-file-into-base64string-and-back-again
Byte[] bytes = File.ReadAllBytes(Server.MapPath(
String file = Convert.ToBase64String(bytes);
HiddenField1.Value = file;
Markup:
<
asp:HiddenField
runat
=
"server"
ID
"HiddenField1"
/>
function
pageLoadHandler() {
var
spreadsheet = $find(
"<%= RadSpreadsheet1.ClientID %>"
);
value = $get(
"<%= HiddenField1.ClientID %>"
).value;
file = b64toBlob(value)
spreadsheet.fromFile(file);
Sys.Application.add_load(pageLoadHandler);
//https://ourcodeworld.com/articles/read/322/how-to-convert-a-base64-image-into-a-image-file-and-upload-it-with-an-asynchronous-form-using-jquery
b64toBlob(b64Data, contentType, sliceSize) {
contentType = contentType ||
''
;
sliceSize = sliceSize || 512;
byteCharacters = atob(b64Data);
byteArrays = [];
for
(
offset = 0; offset < byteCharacters.length; offset += sliceSize) {
slice = byteCharacters.slice(offset, offset + sliceSize);
byteNumbers =
Array(slice.length);
i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
byteArray =
Uint8Array(byteNumbers);
byteArrays.push(byteArray);
blob =
Blob(byteArrays, { type: contentType });
return
blob;
Resources Buy Try