Feature: MS Excel (xlsx) Import/Export

Microsoft Excel files can be used to import/export devices. Several
import bugs were also fixed in the process.
This commit is contained in:
Gary Sharp
2017-03-25 15:37:28 +11:00
parent ed66f4f285
commit 5ce9e51ae7
51 changed files with 1959 additions and 1083 deletions
@@ -103,6 +103,8 @@
<Compile Include="DataModelExtension\DocumentTemplateExtensions.cs" />
<Compile Include="DataModelExtension\JobSubTypeExtensions.cs" />
<Compile Include="DataModelExtension\JobTypeExtensions.cs" />
<Compile Include="MvcExtensions\File\FileContentSpanResult.cs" />
<Compile Include="MvcExtensions\File\FileExtensions.cs" />
<Compile Include="MvcExtensions\JsonNet\JsonDotNetValueProviderFactory.cs" />
<Compile Include="MvcExtensions\JsonNet\JsonNetResult.cs" />
<Compile Include="MvcExtensions\PartialCompiled\PartialCompiledHtmlExtensions.cs" />
@@ -0,0 +1,34 @@
using System;
using System.Web;
using System.Web.Mvc;
namespace Disco.Web.Extensions
{
public class FileContentSpanResult : FileResult
{
public byte[] FileBuffer { get; private set; }
public int Start { get; private set; }
public int Length { get; private set; }
public FileContentSpanResult(byte[] fileBuffer, int start, int length, string contentType) : base(contentType)
{
if (fileBuffer == null)
throw new ArgumentNullException(nameof(fileBuffer));
if (start < 0 || start >= fileBuffer.Length)
throw new ArgumentOutOfRangeException(nameof(start));
if (start + length > fileBuffer.Length)
throw new ArgumentOutOfRangeException(nameof(length));
FileBuffer = fileBuffer;
Start = start;
Length = length;
}
protected override void WriteFile(HttpResponseBase response)
{
response.OutputStream.Write(this.FileBuffer, Start, Length);
}
}
}
@@ -0,0 +1,17 @@
using System.Web.Mvc;
namespace Disco.Web.Extensions
{
public static class FileExtensions
{
public static FileContentSpanResult File(this IController controller, byte[] fileBuffer, int start, int length, string contentType, string fileDownloadName)
{
return new FileContentSpanResult(fileBuffer, start, length, contentType)
{
FileDownloadName = fileDownloadName
};
}
}
}