Exported excel file is protected

  • 2p
    Elizabeth yoon2p 3 months, 2 weeks ago

    Hello all.
    I am saving the content of farpoint spreadsheet to an excel file using the SaveExcel() method.
    the data is saved but the sheet becomes protected.
    Is there any other option to save the data into the sheet as unprotected.

    Thanks in advance.

  • 2p
    Elizabeth yoon2p 3 months, 2 weeks ago

    Post isn’t modify. My code is

    Private Sub frmBatchReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            spDMT.SelectionBlockOptions = FarPoint.Win.Spread.SelectionBlockOptions.Columns
            spDMT.ActiveSheet.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.MultiRange
            spDMT_Sheet1.SelectionUnit = FarPoint.Win.Spread.Model.SelectionUnit.Column
            spDMT2.Visible = False
        End Sub
    End Class
    
        Private Sub btnDownload_DMT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload_DMT.Click
            Dim s As String
            Dim selections As Integer, j As Integer
            selections = spDMT.ActiveSheet.SelectionCount
            For j = 0 To selections - 1
                Dim cr As FarPoint.Win.Spread.Model.CellRange
                cr = spDMT.ActiveSheet.GetSelection(j)
                s = spDMT.ActiveSheet.GetClip(cr.Row, cr.Column, cr.RowCount, cr.ColumnCount)
                spDMT2.Sheets(0).SetClip(cr.Row, cr.Column, cr.RowCount, cr.ColumnCount, s)
            Next
    
            Dim sfd As New SaveFileDialog()
            Dim ss As System.IO.Stream
            sfd.Filter = "excel files (*.xls)|*.xls"
            sfd.FilterIndex = 2
            sfd.RestoreDirectory = True
            If sfd.ShowDialog() = DialogResult.OK Then
                ss = sfd.OpenFile()
                spDMT2_Sheet1.Protect = False
                spDMT2.SaveExcel(ss, FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders)
                ss.Close()
            End If
    
        End Sub
  • 117p
    Sean Lawyer117p 3 months, 2 weeks ago

    Hi,

    I wonder if the code setting Protect is setting it on the wrong SheetView instance? Try this code instead:
    spDMT2.Sheets(0).Protect = False
    It’s possible that spDMT2_Sheet1 (the original sheet in the workbook, from design time) was replaced with a different instance and that code is setting Protect on the wrong SheetView.

    If that doesn’t fix the issue, then please post a small sample. It should work to set Protect = False in the sheet to make the cells editable (even when locked) in the exported Excel file.

    Regards,
    -Sean

  • 2p
    Elizabeth yoon2p 3 months, 2 weeks ago

    Hi. Thank you for the answer.
    I tried to solve that you suggested way. But export file is still protect mode.
    I want to post a small sample, but this spread content connected db procedure.
    I just don’t know what to do. T.T

  • 23p
    GinaDan23p 3 months, 2 weeks ago

    Hi,

    Can you put some test data in the sample? It does not need to be bound to a database. If that works fine, could some of the types from the database be read-only?

    Also, try setting protect to false for all the sheets and see if that makes a difference.

    -Gina

  • 2p
    Elizabeth yoon2p 3 months, 2 weeks ago

    Hi.
    I tried to set protect to false for all the sheets, but still protect mode.
    Not only in code, but also in Spread Designer settings unchecked protect mode.(in toolbar confirm – sheet confirm – protect check)
    But I found something strange.
    if i just add “FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders” code to SaveExcel() method, export file saved protected mode.
    But if i remove it, file open well.
    I want to export the user selected column as an excel file. but if i remove that code, export file does not have a column header.

  • 23p
    GinaDan23p 3 months, 2 weeks ago

    Hi,

    If you try a simple example like this, is the sheet still protected? Also, what version of Spread are you using?

    fpSpread1.Sheets[0].ColumnHeader.Columns[0].Label = “North”;
    fpSpread1.Sheets[0].ColumnHeader.Columns[1].Label = “South”;
    fpSpread1.Sheets[0].ColumnHeader.Columns[2].Label = “East”;
    fpSpread1.Sheets[0].ColumnHeader.Columns[3].Label = “West”;
    fpSpread1.Sheets[0].Cells[1, 1].Text = “Cell Text”;

    private void button1_Click(object sender, EventArgs e)
    {
    fpSpread1.Sheets[0].Protect = false;
    fpSpread1.SaveExcel(“C:\\Program Files (x86)\\GrapeCity\\protecttest.xlsx”, FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat | FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders);
    }

    Thanks, Gina

  • 2p
    Elizabeth yoon2p 3 months, 2 weeks ago

    Hi. I using spread studio 9.
    That path of code was a little strange, so I switched it. So it was well executed, The saved files were OK.

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    FpSpread1.Sheets(0).Protect = False
    FpSpread1.SaveExcel(“C:\Users\sjyoo\protecttest.xlsx”, FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat Or FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    FpSpread1.Sheets(0).ColumnHeader.Columns(0).Label = “North”
    FpSpread1.Sheets(0).ColumnHeader.Columns(1).Label = “South”
    FpSpread1.Sheets(0).ColumnHeader.Columns(2).Label = “East”
    FpSpread1.Sheets(0).ColumnHeader.Columns(3).Label = “West”
    FpSpread1.Sheets(0).Cells(1, 1).Text = “Cell Text”

    End Sub
    End Class

  • 23p
    GinaDan23p 3 months, 2 weeks ago

    Hi,

    Does your database data work with this test code or is it protected? I used V10 to test, but V9 is recent. I also tried saving to xls and to a stream, but that still worked fine with my test data.

    Thanks, Gina

  • 2p
    Elizabeth yoon2p 2 months, 3 weeks ago

    Hi.
    I can’t stll solve this problem. But i found it. When I added the flag, file doesn’t open.(FarPoint.Excel.ExcelSaveFlag.UseOOXMLFormat or FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders etc..)
    I thought that ‘SaveCustomColumnHeaders’ has problem. but all flags was problem.
    File is protect mode whether used code ‘spreadname.Sheets(0).Protect = False or spreadname..ActiveSheet.Protect = False’
    But I need the flag function…. Please send me any answer.. Thanks in advance.

  • 23p
    GinaDan23p 2 months, 3 weeks ago

    Hi,

    When you say the file does not open, do you get an error or does the file open fine, but you cannot edit it because it is protected? The flags should not be an issue with the protect setting. What sort of data are you binding to (text, images)? You should be able to create a small dataset and see if you can reproduce the problem. If that works, you could send us a small working example that reproduces the problem.

    For example:

    DataSet ds = new DataSet();
    DataTable emp = new DataTable("Employees");
    DataTable div = new DataTable("Division");
    emp.Columns.Add("LastName");
    emp.Columns.Add("FirstName");
    emp.Rows.Add(new Object[] {"Jones", "Marianne"});
    emp.Rows.Add(new Object[] {"Fieldes", "Anna"});
    div.Columns.Add("Section");
    div.Columns.Add("Specialty");
    div.Rows.Add(new Object[] {"Finance", "Taxes"});
    div.Rows.Add(new Object[] {"Mergers", "Legal"});
    ds.Tables.AddRange(new DataTable[] {emp, div});
    fpSpread1.DataSource = ds;
    fpSpread1.DataMember = "Division";

    Thanks, Gina

  • 13p
    Kevin Ashley13p 2 months, 3 weeks ago

    Hello,

    I tried to replicate the issue with a sample, but I couldn’t see it. Please try out the attached sample and see if you can change it to make it show the issue.

    Regards,
    Kevin

    Attachments:
    You must be logged in to view attched files.
Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to create new topics.