Ruby Axlsx:如何从另一个工作表中获取值

时间:2017-05-31 14:19:41

标签: ruby-on-rails ruby axlsx

如果我有两个工作表,并且我正在尝试从另一个工作表访问值。是否有一种来自axlsx gem的方法可以做到这一点?

<div class="equal-height-container">
  <div class="first">
  <div class="first-a"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam quasi similique amet voluptatem molestiae nostrum ab nesciunt blanditiis repellendus quos, sequi sunt, dolorem quis facilis mollitia nemo modi doloribus quo.</p></div>
    <div class="first-b">  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat quisquam, veritatis ducimus, vero magnam hic quia pariatur asperiores laudantium quod nobis perspiciatis, expedita quo reprehenderit quasi iusto ullam error reiciendis.</p></div>
   
  </div>

  <div class="second">
    <div class="second-a">A</div>
    <div class="second-b">B</div>
    <div class="second-c">C</div>
  </div>
</div>

如果我现在在工作表B中,并且想要使用表A中的值(例如A中的行)执行一些计算。有没有办法做到这一点?

2 个答案:

答案 0 :(得分:1)

在这里,首先将工作表A放在身边,然后在将图表添加到工作表B上时使用它。

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.swoddz.swoddz, PID: 371
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.remove(ArrayList.java:477)
        at com.example.swoddz.swoddz.BetSwipe$1.removeFirstObjectInAdapter(BetSwipe.java:63)
        at com.lorentzos.flingswipe.SwipeFlingAdapterView$1.onCardExited(SwipeFlingAdapterView.java:223)
        at com.lorentzos.flingswipe.FlingCardListener$1.onAnimationEnd(FlingCardListener.java:256)
        at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1121)
        at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1149)
        at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1309)
        at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
        at android.animation.AnimationHandler.-wrap2(AnimationHandler.java)
        at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:925)
        at android.view.Choreographer.doCallbacks(Choreographer.java:702)
        at android.view.Choreographer.doFrame(Choreographer.java:635)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6682)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'

答案 1 :(得分:0)

您可以执行以下操作:

sheet_a = wb.add_worksheet(name: "Table A") do |sheet|
  sheet
end

wb.add_worksheet(name: "Table B") do |sheet|
   puts sheet_a.name
end