We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Simple creation and saving of a new file

Thread ID:

Created:

Updated:

Platform:

Replies:

116201 Apr 23,2014 07:31 AM May 3,2014 01:18 AM WinRT 4
loading
Tags: XlsIO
doug mcdonald
Asked On April 23, 2014 07:31 AM

Dear Sir/Madam,


I'm trying to evaluate the usage of the XlsIO control for use in a windows 8 application.
I'm hoping to use the control as part of a Windows 8 Runtime component and have created a project with the correct references.

In my simple example, the control appears to create a file, but doesn't seem to write any contents, nor save the file correctly when I try.

My very simple example class is attached to the this post, would it be possible for someone to let me know what I may be doing incorrectly here? I've tried a few ways to write content to a file but I can't seem to get them to work.

At the moment the SaveAsAsync() function is returning false, which doesn't feel correct, and the file when created when I try to open it, tells me the extension isn't the same format as the extension, which seems like I've just created a blank file, rather than the XlsIO control creating the correct mime/content types etc.

Any pointers would be greatly appreciated.

Regards,

Doug


Prasanth M [Syncfusion]
Replied On April 28, 2014 07:58 AM

Hi Doug,

Thank you for using Syncfusion products.

As you have mentioned we could not find the attachment. Could you please get back to us with the simplified sample attachment which help us to investigate further on this. Also, we have attached the simple sample for your reference. Could you please cross check your sample and our simple sample code snippet which may helps you to resolve the issue, if still the issue reproduces at your end then please get back to us with the missed attachment.

Please let us know if you need any clarification.

Regards,

Prasanth

 


Attachment: CreateSpreadSheet_8a44e3b6.zip

doug mcdonald
Replied On April 28, 2014 08:10 AM

Hi Prasanth,

 

I've re-attached the zip file and uploader on the forum says 'File Uploaded Successfully'.

Please let me know if this attached correctly, or perhaps if not, I could sent it directly, do you have a direct email I could fire the example too? 

Kind Regards,

Doug


Attachment: DemoXlsExport_5d21ad8c.zip

doug mcdonald
Replied On April 28, 2014 08:21 AM

Additionally, if it's any help, here is my C# windows runtime component code:

using Syncfusion.XlsIO;
using System;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Storage;

namespace WindowsRuntimeComponent1
{
    public sealed class TestSpreadsheet
    {
        public static IAsyncOperation<string> ButtonPress(StorageFile file)
        {
            var task = Task.Run<string>(async () => await SaveSpreadsheet(file));

            return task.AsAsyncOperation();
        }

        public static IAsyncOperation<string> SaveSpreadsheet(StorageFile file)
        {
            var task = Task.Run<string>(async () =>
            {
                var engine = new ExcelEngine();
                var app = engine.Excel;

                var book = app.Workbooks.Create();
                book.Version = ExcelVersion.Excel97to2003;
                var sheet = book.Worksheets[0];

                sheet.InsertRow(1, 1);
                sheet.InsertColumn(1, 1);

                sheet.Range["A1"].Text = "I'm some content!";

                var res = await book.SaveAsAsync(file, ExcelSaveType.SaveAsXLS);

                return res.ToString();
            });

            return task.AsAsyncOperation();
        }
    }
}

 

and here's my calling winjs code:

                button.onclick = function () {

                    var filePicker = new Windows.Storage.Pickers.FileSavePicker;
                    filePicker.suggestedStartLocation = Windows.Storage.KnownFolders.documentsLibrary;
                    filePicker.suggestedFileName = "Superfile";
                    filePicker.fileTypeChoices.insert("Excel Files", [".xls"]);

                    filePicker.pickSaveFileAsync().then(function(file) {

                        WindowsRuntimeComponent1.TestSpreadsheet.buttonPress(file).then(function(res) {
                            document.getElementById('res').innerText = "Export should have: " + res;
                        });
                    });
                };

 


Prasanth M [Syncfusion]
Replied On May 3, 2014 01:18 AM

Hi Doug,

We have created an incident 124152 for the above query. We would like to inform you, to follow the incident 124152 for further updates.

Regards,
Prasanth

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;