Skip to content
This repository was archived by the owner on Jul 26, 2021. It is now read-only.

[WIP] Edit Excel file cells data. #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/GroupDocs.Editor.MVC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="GroupDocs.Editor, Version=20.8.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL">
<HintPath>..\packages\GroupDocs.Editor.20.8.0\lib\net20\GroupDocs.Editor.dll</HintPath>
<Reference Include="GroupDocs.Editor, Version=20.10.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL">
<HintPath>..\packages\GroupDocs.Editor.20.10.0\lib\net40\GroupDocs.Editor.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp">
<Private>True</Private>
Expand Down
5 changes: 5 additions & 0 deletions src/Products/Common/Entity/Web/PageDescriptionEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class PageDescriptionEntity
[JsonProperty]
private string data;

/// <summary>
/// Sheet name.
/// </summary>
public string sheetName { get; set; }

public void SetData(string data)
{
this.data = data;
Expand Down
14 changes: 9 additions & 5 deletions src/Products/Editor/Controllers/EditorApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ public HttpResponseMessage SaveFile(EditDocumentRequest postedData)
saveOptions.EnablePagination = true;
}

if (saveOptions is SpreadsheetSaveOptions)
{
saveOptions.WorksheetNumber = postedData.getPageNumber() + 1;
}

using (FileStream outputStream = File.Create(tempPath))
{
editor.Save(htmlContentDoc, outputStream, saveOptions);
Expand Down Expand Up @@ -648,18 +653,17 @@ private LoadDocumentEntity LoadDocument(string guid, string password)
for (var i = 0; i < documentInfo.PageCount; i++)
{
// Let's create an intermediate EditableDocument from the i tab
SpreadsheetEditOptions sheetEditOptions = new SpreadsheetEditOptions();
sheetEditOptions.WorksheetIndex = i; // index is 0-based
EditableDocument tabBeforeEdit = editor.Edit(sheetEditOptions);
editOptions.WorksheetIndex = i; // index is 0-based
EditableDocument sheetBeforeEdit = editor.Edit(editOptions);

// Get document as a single base64-encoded string, where all resources (images, fonts, etc)
// are embedded inside this string along with main textual content
string allEmbeddedInsideString = tabBeforeEdit.GetEmbeddedHtml();
string allEmbeddedInsideString = sheetBeforeEdit.GetEmbeddedHtml();
PageDescriptionEntity page = new PageDescriptionEntity();
page.SetData(allEmbeddedInsideString);
page.number = i + 1;
loadDocumentEntity.SetPages(page);
tabBeforeEdit.Dispose();
sheetBeforeEdit.Dispose();
}
}
else if (editOptions is PresentationEditOptions)
Expand Down
13 changes: 13 additions & 0 deletions src/Products/Editor/Entity/Web/Request/EditDocumentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class EditDocumentRequest : LoadDocumentEntity
[JsonProperty]
private String password;

[JsonProperty]
private int pageNumber;

public String getContent()
{
return content;
Expand All @@ -34,5 +37,15 @@ public void setPassword(String password)
{
this.password = password;
}

public int getPageNumber()
{
return pageNumber;
}

public void setPageNumber(int pageNumber)
{
this.pageNumber = pageNumber;
}
}
}
2 changes: 1 addition & 1 deletion src/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
<package id="Castle.Core" version="4.3.1" targetFramework="net45" />
<package id="GroupDocs.Editor" version="20.8.0" targetFramework="net45" />
<package id="GroupDocs.Editor" version="20.10.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Cors" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
Expand Down