Coder Social home page Coder Social logo

Comments (3)

shanshanzheng-dev avatar shanshanzheng-dev commented on August 10, 2024 1

Hi @manuelsidler Thanks for confirming. I can repro this problem. We'll be looking into the issue and report back if we have a suggestion for you. Thanks.

from office-js.

shanshanzheng-dev avatar shanshanzheng-dev commented on August 10, 2024

Hi @manuelsidler Thanks for reporting. About this API, you can follow this reference: https://learn.microsoft.com/en-us/javascript/api/excel/excel.range?view=excel-js-preview#excel-excel-range-copyfrom-member(1),
you could try this code snippet, seem you have to set an initial range:

async function run() {
  await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getActiveWorksheet();

    const range = "A1:H1"; // more examples that won't work: 'H1', 'H1:M2', 'A1:H2', ...
    const sourceRange = sheet.getRange(range);

    sheet.getRange("A2").copyFrom(sourceRange, Excel.RangeCopyType.all);
    
    await context.sync();
  });
}

Please let me know if resolve your problem. Thanks.

from office-js.

manuelsidler avatar manuelsidler commented on August 10, 2024

@shanshanzheng-dev using an initial range helps, thank you. But I still don't understand why the error occurs only when I explicitly use the "H" column for the range. The snippet I posted works fine with ranges like A1:K1, G1:I1 and so on (without specifying an initial range):

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getActiveWorksheet();

    const range = 'A1:I1' // works without specifying an initial range
    const sourceRange = sheet.getRange(range)

    sheet.getRange().copyFrom(sourceRange, Excel.RangeCopyType.all)

    await context.sync();
  });

from office-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.