Haven't ever done it myself, but since it is possible in Excel [1] it is a matter of working backward from a Workbook set up the way you want, seeing what properties are set where and doing those things in POI to mimic or duplicate the setup. Create an empty workbook set up per those instructions, save it, then unzip the XLSX file and see how the XML is put together. It may be that you would need to reference some properties in the low-level XML representation not yet exposed in the higher-level APIs.
I don't think anyone has written up how to do this in POI, but if you figure it out and submit sample code and/or patches we would love to add another code example to the documentation. [1] https://support.office.com/en-us/article/lock-or-unlock-specific-areas-of-a-protected-worksheet-75481b72-db8a-4267-8c43-042a5f2cd93a On Thu, Jan 18, 2018 at 6:05 AM [email protected] < [email protected]> wrote: > Hello, > I am using poi v3.12 and I need to disable the first row in each sheet of > my workbook. I am using XSSF. I have found two solutions: > 1. worksheet.createFreezePane(0,1); > 2. worksheet.protectSheet("password"); and then setLocked(false) for all > cells except in the first row. > > The first solution didnt work. > I can't use the second because the user will download the file and I don't > know how many rows he will insert. So, I cant make a loop to > setLocked(false) for the rows that I dont know that user will add... > > Any ideas how to solve this? There is no way to set locked to false in > entire sheet, except in the first row? > > Thanks, > Marco > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
